Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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

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

JENKINS_HOME=/srv/jenkins
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
/usr/share/tomcat6

[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
hello
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"/>
</Context>

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

share|improve this answer

According to the documentation I've read and a couple examples above, Jenkins uses your Tomcat user's home directory and searches for a .jenkins in that folder. Make sure your Tomcat user's home directory is set to a value you expect, /opt/apache/tomcat for example, and create a .jenkins symlink in that folder pointing to where your Jenkins folder lives.

ln -s /path/to/jenkins_home /opt/apache/tomcat/.jenkins
share|improve this answer

Your Answer

 
discard

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.