Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relocating JENKINS_HOME on Windows when installed as service

To free up space on C:, I would like to move my Jenkins data files (specifically the \jobs directory) from the default installation directory C:\Program Files (x86)\Jenkins to F:\Jenkins\home. I think what I need to do is set the JENKINS_HOME environment variable to F:\Jenkins\home. But no matter what I try, the JENKINS_HOME environment variable is always set to the location of jenkins.exe.

Related:

  • How to change Jenkins default folder on Windows?
  • JIRA issue JENKINS-13530 JENKINS_HOME ignored on Bundled Windows EXE was closed as "not an issue"

Here is what I've tried so far:

  1. Moved jenkins data to F:\Jenkins\home
  2. Stop the running jenkins service
  3. Uninstall the jenkins service with jenkins.exe uninstall
  4. Uninstall jenkins
  5. Delete %HOMEPATH%\.jenkins directory
  6. Delete old jenkins install directory
  7. Download latest MSI installer v1.597
  8. Installed to C:\Program Files (x86)\Jenkins2 (renamed to ensure there are no stale values in the registry or config files)
  9. Set system-level environment variable JENKINS_HOME to F:\Jenkins\home
  10. Set user-level environment variable JENKINS_HOME to F:\Jenkins\home
  11. Modified jenkins.xml to use <env name="JENKINS_HOME" value="F:\Jenkins\home"/>
  12. Started the Jenkins service

At this point, when I look at the system configuration, JENKINS_HOME is set to C:\Program Files (x86)\Jenkins2. So it seems it must always be set to the location of jenkins.exe.

Maybe I've answered my own question. I'd like to have the program and data separate, if possible. Do I have to install jenkins to my F:\ drive? Or, is there a way to simply split off the jobs directory and leave everything else on C:?

Thanks!

EDIT : I did not have to move JENKINS_HOME, but instead was able to configure the workspace and builds directories, which moved all the heavy disk usage over to F:. The settings I chose were:

Workspace Root Directory = F:/Jenkins/workspace/${ITEM_FULLNAME} Build Record Root Directory = F:/Jenkins/jobs/${ITEM_FULL_NAME}/builds

I manually migrated these directories so they would not have to be recreated. During this process I did lose my build history, but I'm okay with that for now.

like image 915
cod3monk3y Avatar asked Jan 19 '15 22:01

cod3monk3y


People also ask

How do I move the Jenkins home directory in Windows?

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.

How do I change the Jenkins workspace folder in Windows?

So if you wish to change the Jenkins workspace, all you've do is change the path of your JENKINS_HOME. For slave nodes, specify the default workspace on the slave machine in the slave configuration under Manage Jenkins > Manage Nodes > > Configure > Remote FS root.


2 Answers

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:

  1. Manage Jenkins
  2. System Configuration
  3. 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

like image 79
Jeanne Boyarsky Avatar answered Sep 17 '22 21:09

Jeanne Boyarsky


Another possibility is to move the entire contents of $JENKINS_HOME.

It does not require editing configuration files, and it preserves the build history.

  1. Stop the running service: jenkins.exe stop

  2. Uninstall the service: jenkins.exe uninstall

  3. Copy C:\Jenkins\home to F:\Jenkins\home

  4. Rename C:\Jenkins to something else, keep it as backup.

  5. Go to F:\Jenkins\home

  6. Reinstall the service: jenkins.exe install

  7. Start Jenkins: jenkins.exe start

Enjoy the new disk space!

like image 39
SpaceMonkey13 Avatar answered Sep 20 '22 21:09

SpaceMonkey13