Simple way to change home directory of Jenkins Server
Recently i came across issue where jenkins server stopped working as the partition on which Jenkins server was installed was full. & since we could not free up any space on the partition as some other applications were installed on it, we decided that we change home directory of jenkins.
So i decided that i should the procedure with you guys.In this tutorial, we will learn how we change home directory of Jenkins. So let’s start…..
(Recommended Read: Install Gitlab on Ubuntu & CentOS : A complete guide )
(Also Read: Complete “Beginners to PRO” guide for GIT commands )
Change home directory of Jenkins Server
Firstly locate the current directory for the jenkins server. You can find the location of current Jenkins home directory by logging into the Jenkins page. Once logged in, goto ‘Manage Jenkins’ & select the options ‘Configure System’. Here first thing you will see will be the path to your Jenkins Home Directory.
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 ~/Jenkins
Now copy all the content from original Jenkins home to this directory,
$ cp -rvf /varlib/jenkins/* ~/jenkins
Once the copy operation has been completed, we will update the environment variable for Jenkins home directory. Environment Variable for jenkins is ‘JENKINS_HOME’, we can update the env varaible with the following command,
$ export JENKINS_HOME=~/jenkins
The home directory for the Jenkins has been changed but the updated values for env varaible will only hold for current session. To permanently update the variable, we need to make changed in ‘.bash_profile’ file located in our home directory & make the following entry,
$ sudo vi ~/.bash_profile
export JENKINS_HOME=~/jenkins
Now last step is to restart the jenkins service to implement the changes,
$ sudo service jenkins restart
Now check the updated path again by logging into the jenkins webpage. You shoud now see the updated path for the home directory.
So this completes our tutorial on how we can change home directory of jenkins server. Hope this was helpful to you. Please do leave any queries or suggestions using the comment box below.
If you think we have helped you or just want to support us, please consider these :-
Connect to us: Facebook | Twitter | Google Plus
Donate us some of your hard earned money:
Linux TechLab is thankful for your continued support.
Originally published at linuxtechlab.com on April 6, 2018.