Set JENKINS_HOME in Tomcat7

Jenkinstomcat7

I'm trying to set up Jenkins in Tomcat7 on Ubuntu. I installed Tomcat7 and deployed jenkins.war, and I now see the Jenkins home page at http://myhost:8080/jenkins, but it's attempting to create the Jenkins directory at /usr/share/tomcat7/.jenkins, which it can't for security reasons. I've already created /srv/jenkins and given the tomcat7 group permissions, and want to set JENKINS_HOME to that path. I've tried adding it to the tomcat configuration in /etc/tomcat7/server.xml:

<GlobalNamingResources>

  <Environment name="JENKINS_HOME" value="/srv/jenkins"
       type="java.lang.String" override="false"/>
  <!-- Default settings -->

And I've also tried adding it to the automatically created context file in ROOT/META-INF/context.xml (there is no $CATALINA_HOME/conf as far as I can tell).

<Context path="/"
        antiResourceLocking="false" >
    <Environment name="JENKINS_HOME" value="/srv/jenkins/" type="java.lang.String"/>
</Context>

But even after restarting tomcat7 I still get the same result (trying to use /usr/share/tomcat7/.jenkins).

Where do I need to set the environment variable for JENKINS_HOME in Tomcat7?

Best Answer

It isn't exactly the solution I prefer, but I created the /usr/share/tomcat7/bin/setenv.sh script as described in catalina.sh.

#!
export JENKINS_HOME=/srv/jenkins

And of course gave it execute permissions with chmod ugo+x setenv.sh.

Related Topic