Change JENKINS_HOME on Red Hat Linux? Change JENKINS_HOME on Red Hat Linux? jenkins jenkins

Change JENKINS_HOME on Red Hat Linux?


Here's an easy way to solve your problem. First, move the Jenkins directory from /var/lib/jenkins to /home/jenkins. Then create a symlink at /var/lib/jenkins pointing to /home/jenkins. And of course, stop the Jenkins service before doing that.

sudo service jenkins stopsudo mv /var/lib/jenkins /homesudo ln -s /home/jenkins /var/lib/jenkinssudo service jenkins start


I managed to change the home location for Jenkins by modifying content of /etc/sysconfig/jenkins file as follows:

JENKINS_HOME="/home/jenkins"


Okay, I reread your question a little bit more closely, lets see if we can figure this out. I am going to list some info that you may or may not know.

  1. The jenkins installation and jenkins home are not the same thing. One is where the war file and other parts that jenkins needs to run live. jenkins_home is where your data is stored. By default, jenkins_home lives in ~/.jenkins. When you start jenkins, it looks for an environment variable to tell it where to find those files.

  2. Jenkins runs as a seperate user, which, by default, is jenkins. This way it doesn't get in the way of you. The jenkins user will not have access to YOUR home directory, so that would be a poor solution. Ideally, it would have its own home directory, /home/jenkins. Your home directory could then be /home/jenkins/.jenkins. You say that folder doesn't exist- if you don't have access to it to create it yourself, that is perfectly fine, you can specify ANY folder. However, the jenkins user must have ownership of that folder to read and write to it.

  3. It looks like Jenkins on redhat will be running with tomcat by default. The documentation for how to set environment variables for tomcat is https://wiki.jenkins-ci.org/display/JENKINS/Tomcat

  4. This all gets set up with a script.https://wiki.jenkins-ci.org/display/JENKINS/JenkinsLinuxStartupScript seems to be the one that is used for this purpose. Even if you don't know anything about shell scripting, this isn't too hard... lines with a # are comments. The first line

    JENKINS_USER=jenkins

sets the name of the user account jenkins will be using. Look down a littlle further, and you'll see the line

export JENKINS_BASEDIR=/home/jenkinsexport CATALINA_OPTS="-DJENKINS_HOME=$JENKINS_BASEDIR/jenkins-home -Xmx512m -Djava.awt.headless=true"

This lets you set a directory to where jenkins should live, and then sets the jenkins_home directory to that /jenkins-home.

For your application, you may want to do something like this

export CATALINA_OPTS="-DJENKINS_HOME=/var/jenkinsmount/home -Xmx512m -Djava.awt.headless=true"

That would then store all of your build data (which is the part that grows!) at /var/jenkinsmount/home ... while leaving the rest of your files in their current location.

I haven't used it on redhat, but hopefully I explained enough for you to actually understand what is going on so that you can get it going!

Other INFO:

https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Unix+daemon