Change the home directory of Jenkins
Description
Jenkins sometimes needs to be migrated, and the home directory will change. This article focuses on how to change the home directory. Due to the different installation methods of jenkins, the home directory is also different. This test environment: Centos6.8 X64. Note: before changing the home directory, be sure to back up the original home directory, because the jenkins directory exists as a file, just package the entire home directory.
How to view the current Jenkins home directory: system management → system settings → home directory → / var/lib/jenkins
I. installed through yum or rpm package
This installation generates a / etc/sysconfig/jenkins file, and the default home directory is / var/lib/Jenkins. You only need to modify this configuration file and restart the jenkins service to change the home directory. Here we take changing to / home/jenkins as an example.
Stop the jenkins service
Service Jenkins stop
Back up home directory data
Tar-zcvf / backup/jenkins.tar.gz / var/lib/jenkins
Migrate the old home directory data to the new home directory
Tar-zxvf / backup/jenkins.tar.gz-C / home/Jenkins
Edit configuration file
Vim / etc/sysconfig/Jenkins
Change to the changed directory
JENKINS_HOME= "/ home/jenkins"
Change the directory owner
Chown-R jenkins.jenkins / home/Jenkins
Restart
Service jenkins restart
II. The first method of installation through tomcat
Open the bin directory of tomcat and edit the catalina.sh file.
In # OS specific support. $var _ must_ be set to either true or false. Add above:
Export JENKINS_HOME= "/ home/jenkins"
Method two
Set the JENKINS_HOME environment variable before starting the Web container.
Edit the profile file: vi / etc/profile
Add at the end of the document
Export JENKINS_HOME=/home/Jenkins
Make the configuration file effective
Source / etc/profile
When finished, remember to restart tomcat.
Finally, for jenkins under windows, please refer to: http://www.cnblogs.com/itech/archive/2011/11/04/2236230.html