Published August 01, 2018 by

Change home directory of Jenkins

Firstly locate the current directory for the Jenkins server. You can find the location of the current Jenkins home directory by logging into the Jenkins page. Once logged in, go to 'Manage Jenkins' & select the options Configure System. Here first thing you will see will be the path to your Jenkins Home Directory.

so as per above image current Jenkins home directory is: /var/lib/jenkins

Now we will create a new folder for the keeping the Jenkins. For this tutorial, we will create a new folder in our home directory.

# sudo mkdir /root/jenkins

Now copy all the content from original Jenkins home to this directory,

# cp -rvf /var/lib/jenkins/* /root/jenkins

Once the copy operation has been completed, we will update the environment variable for the Jenkins home directory. Environment Variable for Jenkins is 'JENKINS_HOME' we can update the env variable with the following command,

# export JENKINS_HOME=~/jenkins

The home directory for the Jenkins has been changed but the updated values for env variable will only hold for the current session. To permanently update the variable, we need to make a change in '.bash_profile' file located in our home directory & make the following entry,

# sudo vim /root/.bash_profile

Enter this entry here

export JENKINS_HOME=/root/jenkins

Now Restart the Jenkins to implement the changes.

Now you can see the new Jenkins home directory is: /root/jenkins