Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:


  <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"/>

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?

share|improve this question

4 Answers 4

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.

share|improve this answer

A symbolic link approach where my jenkins-data go to a backed-up filesystem.

[root@lx08 tomcat6]# ln -s /data01/jenkins .jenkins
[root@lx08 tomcat6]# ls -la
total 12
drwxrwxr-x    3 root root   4096 Dec 27 13:00 .
drwxr-xr-x. 181 root root   4096 Dec 27 11:28 ..
drwxr-xr-x    2 root root   4096 Dec 27 11:28 bin
lrwxrwxrwx    1 root tomcat   12 Dec 27 11:28 conf -> /etc/tomcat6
lrwxrwxrwx    1 root root     15 Dec 27 13:00 .jenkins -> /data01/jenkins
lrwxrwxrwx    1 root root     23 Dec 27 11:28 lib -> /usr/share/java/tomcat6
lrwxrwxrwx    1 root root     16 Dec 27 11:28 logs -> /var/log/tomcat6
lrwxrwxrwx    1 root root     23 Dec 27 11:28 temp -> /var/cache/tomcat6/temp
lrwxrwxrwx    1 root root     24 Dec 27 11:28 webapps -> /var/lib/tomcat6/webapps
lrwxrwxrwx    1 root root     23 Dec 27 11:28 work -> /var/cache/tomcat6/work
[root@lx08 tomcat6]# pwd

[root@lx08 tomcat6]# export JENKINS_HOME=http://localhost:8080/jenkins
[root@lx08 tomcat6]# java -jar /usr/share/tomcat6/webapps/jenkins/WEB-INF/lib/jenkins-core-1.495.jar  "TestJob" echo hello
share|improve this answer

I set it in /etc/default/tomcat7. For your example, append this line:

share|improve this answer

A simpler way is to edit the context descriptor of the Tomcat servlet ($CATALINA_HOME/conf/config.xml) and add the folowing line:

<Context ...>
  <Environment name="JENKINS_HOME" value="/path/to/jenkins_home/" type="java.lang.String"/>

Viewed in https://wiki.jenkins-ci.org/display/JENKINS/Tomcat

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.