Modify Jenkins home directory step

In the process of using Jenkins for continuous integration, after many builds, it is found that sometimes the system prompts insufficient disk space during the build. At this time, it is found that the home directory mount area of ​​Jenkins is placed in the server root directory, which takes up a lot of space. At this time, in addition to expanding the disk of the server, another solution is to modify the home directory of Jenkins and put it under the partition that occupies a large amount of disk space.
 
Several ways to modify the Jenkins home directory
! ! ! ! ! Pay special attention, in general, try not to modify the home directory of Jenkins. I have caused the service to hang when I modified it, and all configurations have been reconfigured.

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
/etc/profile

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-->
Not recommended
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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325352673&siteId=291194637