Relocating JENKINS_HOME on Windows when installed as service
Another possibility is to move the entire contents of $JENKINS_HOME.
It does not require editing configuration files, and it preserves the build history.
Stop the running service:
jenkins.exe stop
Uninstall the service:
jenkins.exe uninstall
Copy C:\Jenkins\home to F:\Jenkins\home
Rename C:\Jenkins to something else, keep it as backup.
Go to F:\Jenkins\home
Reinstall the service:
jenkins.exe install
Start Jenkins:
jenkins.exe start
Enjoy the new disk space!
For Jenkins 2.0, it was only necessary to add a system environment variable called "JENKINS_HOME" that points to the new location. The steps I used:
- Stop the container hosting Jenkins (e.g. Tomcat).
- Add a system environment variable called "JENKINS_HOME" that points to the new location.
- Restart the container hosting Jenkins.
Pre Jenkins 2.121
JENKINS_HOME is where Jenkins is installed which is not what you want to change. After you start up Jenkins, go to:
- Manage Jenkins
- System Configuration
- Click the first "advanced" button
This gives you text fields where you can change the directory for the workspace and builds directories. Those are the two directories that use a good bit of disk space. Note that it will not move history. If you want to move the existing workspaces/etc, you'll need to manually copy them over.
Post 2.121 You have to set properties (not through the UI). The system property to use is jenkins.model.Jenkins.buildsDir.
https://jenkins.io/doc/upgrade-guide/2.121/#ui-option-for-custom-builds-and-workspace-directories-on-the-master-has-been-removed https://wiki.jenkins.io/display/JENKINS/Features+controlled+by+system+properties
For WINDOWS:
Copy all data from
C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins.jenkins
to D:\Jenkins\home
Go to Jenkins installed folder C:\Program Files\Jenkins
Stop the running Jenkins service from the command line -
jenkins.exe stop
Uninstall the Jenkins service from the command line -
jenkins.exe uninstall
Update
jenkins.xml
as<env name="JENKINS_HOME" value="D:\JenkinsHome"/>
Install the Jenkins service from the command line-
jenkins.exe install
Start the Jenkins service from the command line-
jenkins.exe start
Login to Jenkins
http://localhost:8080
Navigate to
Manage Jenkins > Configure System
Verify Home directory must point to D:\JenkinsHome