What is Jenkins Home?
When Jenkins runs, it stuffs all of its logs, cloned repos, plugin configurations and build artifacts into the Jenkins Home folder. Basically, every ounce of configuration that exists for your Jenkins installation is contained in the Jenkins Home directory. The Jenkins Home folder represents the heart and soul of your CI/CD instance.
Back up this folder, and you’ve backed up the entire server. Delete this folder and the next time you run the Jenkins WAR file it will assume it’s a brand new installation and configure itself from scratch. The importance and significance of the Jenkins Home folder can not be understated.
Where is JENKINS_HOME located?
The location of the Jenkins Home folder depends on your operating system, and if you are Linux based, it depends on the distribution.
There are standard Jenkins Home locations the CI/CD tool defaults to, although these locations will change if you configure a JENKINS_HOME environment variable.
|Your intro to GitHub Actions training course|
Here’s how to get started with GitHub Actions:
Follow these tutorials and you’ll learn GitHub Actions fast.
Jenkins Home on Windows defaults to a folder named .jenkins in the home directory of the user that starts the Jenkins server. On my own Windows 10 Jenkins server, where the user is named Owner, the Jenkins home location is:
Note that this is the default Jenkins Home location when you run the Jenkins WAR file. If you uses the Jenkins installer to configure the instance, the Windows JENKINS_HOME will be:
The Jenkins Home folder on Ubuntu Linux is located at:
Change Jenkins Home on Windows
The default Jenkins Home locations are used only if a JENKINS_HOME environment variable is not pre-configured. To change the location of Jenkins Home on Windows, simply add or update the JENKINS_HOME system variable and restart the CI/CD tool. When it restarts, the new Jenkins Home location will be used.
Change JENKINS_HOME on Ubuntu
A change to the JENKINS_HOME location on Ubuntu is a bit more complicated, as Jenkins must be given rights to access the new folder, and the etc/default/jenkins file must be updated.
The following set of commands would change the Jenkins Home location on Ubuntu Linux from the default to a new folder named /home/my_jenkins_home
sudo -i sudo service jenkins stop mkdir /home/my_jenkins_home sudo chown jenkins:jenkins /home/my_jenkins_home sudo cp -prv /var/li/jenkins /home/my_jenkins_home sudo usermod -d /home/my_jenkins_home jenkins sudo nana /etc/default/jenkins
After the Jenkins usermod command completes, open the /etc/default/jenkins file and update the JENKINS_HOME variable contained within.
# jenkins home location JENKINS_HOME=/home/my_jenkins_home
The next time you start Jenkins, the popular CI/CD tool will read from the new JENKINS_HOME location.