At work, because the default home directory space of Jenkins is too small, it is necessary to modify the default home directory of Jenkins to another directory. This article details changing the home directory of Jenkins.
Note: It cannot be changed while Jenkins is running. Please stop Jenkins first.
1. Change the home directory of Jenkins in the Windows environment
In a Windows environment, the Jenkins home directory is C:\Documents and Settings\AAA\.jenkins by default.
It can be modified by setting environment variables, for example: JENKINS_HOME=C:\jenkins, and restarting jenkins.
2. Change the home directory of Jenkins in the Linux environment
In a Linux environment, the Jenkins home directory is /root/.jenkins by default
Jenkins stores all data files in this directory. You can change it in the following ways:
1. Use the management tool of your web container to set the JENKINS_HOME environment parameter. (I use this method personally)
Open the bin directory of tomcat and edit the catalina.sh file. Add in # OS specific support. $var _must_ be set to either true or false. Above: export JENKINS_HOME="" Fill in your path in quotes.
2. Set the JENKINS_HOME environment variable before starting the web container .
Login as root user Edit the profile file: vi /etc/ profile Add at the end: export JENKINS_HOME = xxxx Save and execute after exit: source /etc/ profile Make the configuration take effect
3. (Not recommended) change the web.xml configuration file in Jenkins.war ( or in the expanded web container)
<!-- if specified, this value is used as the Hudson home directory --> <env-entry> <env-entry-name>HUDSON_HOME</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value></env-entry-value> </env-entry> <!-- Fill in the path in the <env-entry-value> node, the Windows system recommends using / to separate the path-->
Note: The online jenkins service needs to be cautious. There are configurations and plug-ins in /root/.jenkins. If the data is not moved after the modification, it is equivalent to reinstalling jenkins.