How to move Jenkns to another drive on Windows?
- Move entire Jenkins directory (typically located in C:\Program Files (x86)\Jenkins) to desired one (e.g. D:\Jenkins) - it can take some time
- Turn off Jenkins
- Open cmd where it is installed (C:\Program Files (x86)\Jenkins) and run
jenkins.exe stop
- Open Services in Windows (Win key and type "Services") and find Jenkins service, right-click and click Stop
- Open cmd where it is installed (C:\Program Files (x86)\Jenkins) and run
- Update environment variables
- Search in Windows for 'environment variables'
- Look for
JENKINS_HOME
in system variables and edit it - Change the value (in our case
D:\Jenkins
)
- Change service "Path to executable"
- Open cmd with Admin privileges (type
cmd
in start and then click 'Run as administrator') - Check Jenkins service info by running
sc qc Jenkins
- Example of response:
[SC] QueryServiceConfig SUCCESS SERVICE_NAME: Jenkins TYPE : 10 WIN32_OWN_PROCESS START_TYPE : 2 AUTO_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : "C:\Program Files (x86)\Jenkins\jenkins.exe" LOAD_ORDER_GROUP : TAG : 0 DISPLAY_NAME : Jenkins DEPENDENCIES : SERVICE_START_NAME : .\Automation
- Notice that
BINARY_PATH_NAME
leads to old place of installation - Run
sc config <service_name> binPath= <path_to_binary>
, e.g.sc config Jenkins binPath= "\"D:\Jenkins\jenkins.exe\""
- You will be notified with response
[SC] ChangeServiceConfig SUCCESS
- In case that you receive
[SC] OpenService FAILED 5: Access is denied.
, you probably forgot to open cmd with admin privileges - Notice the space after
binPath=
and also make sure to escape all quote ("
) characters - Run
sc qc Jenkins
again to confirm the changes are made
- Open cmd with Admin privileges (type
- Run Jenkins by executing
jenkins.exe start
in cmd opened in new installation folder- Check if the service is up and running (you probably need to Refresh the services list using button at the top bar or simply by clicking F5)
- Open your configured Jenkins URL, go to
Manage Jenkins
->Configure System
and check ifHome directory
is set properly - Congratulations, you can now run your jobs and use Jenkins as usual!
Sources: Modifying the “Path to executable” of a windows service Change Jenkins Home location Move Jenkins Installation Directory and Assign it a Dedicated Windows User Account