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?
It isn't exactly the solution I prefer, but I created the
/usr/share/tomcat7/bin/setenv.sh
script as described incatalina.sh
.And of course gave it execute permissions with
chmod ugo+x setenv.sh
.I set it in
/etc/default/tomcat7
. For your example, append this line:A symbolic link approach where my jenkins-data go to a backed-up filesystem.
A simpler way is to edit the context descriptor of the Tomcat servlet ($CATALINA_HOME/conf/config.xml) and add the folowing line:
Viewed in https://wiki.jenkins-ci.org/display/JENKINS/Tomcat
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.