How to change workspace and build record Root Directory on Jenkins?

JenkinsWorkspace

Jenkins Problem Overview


I would like Jenkins' data to be written to drive "E:" since this is the large drive on the server. Jenkins itself is installed on "C:".

How do I do that?

The default configuration that I saw is:

> Workspace Root Directory: ${ITEM_ROOTDIR}/workspace
> Build Record Root Directory: ${ITEM_ROOTDIR}/builds

Will the following changes help me achieve what I need?

> Workspace Root Directory: E:/Jenkins/workspace
> Build Record Root Directory: E:/Jenkins/builds/${ITEM_FULL_NAME}

In addition, what does "${ITEM_FULL_NAME}" mean?

Jenkins Solutions


Solution 1 - Jenkins

I figured it out. In order to save your Jenkins data on other drive you'll need to do the following:

Workspace Root Directory: E:\Jenkins${ITEM_FULL_NAME}\workspace
Build Record Root Directory: E:\Jenkins${ITEM_FULL_NAME}\builds

Change Directory

Solution 2 - Jenkins

You can modify the path on the config.xml file in the default directory

<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
<workspaceDir>D:/Workspace/${ITEM_FULL_NAME}</workspaceDir>
<buildsDir>D:/Logs/${ITEM_ROOTDIR}/Build</buildsDir>

Solution 3 - Jenkins

EDIT: Per other comments, the "Advanced..." button appears to have been removed in more recent versions of Jenkins. If your version doesn't have it, see knorx's answer.

I had the same problem, and even after finding this old pull request I still had trouble finding where to specify the Workspace Root Directory or Build Record Root Directory at the system level, versus specifying a custom workspace for each job.

To set these:

  1. Navigate to Jenkins -> Manage Jenkins -> Configure System
  2. Right at the top, under Home directory, click the Advanced... button: advanced button under Home directory
  3. Now the fields for Workspace Root Directory and Build Record Root Directory appear: additional directory options
  4. The information that appears if you click the help bubbles to the left of each option is very instructive. In particular (from the Workspace Root Directory help): > This value may include the following variables: > > * ${JENKINS_HOME} — Absolute path of the Jenkins home directory > * ${ITEM_ROOTDIR} — Absolute path of the directory where Jenkins stores the configuration and related metadata for a given job > * ${ITEM_FULL_NAME} — The full name of a given job, which may be slash-separated, e.g. foo/bar for the job bar in folder foo > >
    The value should normally include ${ITEM_ROOTDIR} or ${ITEM_FULL_NAME}, otherwise different jobs will end up sharing the same workspace.

Solution 4 - Jenkins

The variables you need are explained here in the jenkins wiki: https://wiki.jenkins.io/display/JENKINS/Features+controlled+by+system+properties

The default variable ITEM_ROOTDIR points to a directory inside the jenkins installation. As you already found out you need:

  • Workspace Root Directory: E:/myJenkinsRootFolderOnE/${ITEM_FULL_NAME}/workspace
  • Build Record Root Directory: E:/myJenkinsRootFolderOnE/${ITEM_FULL_NAME}/builds

You need to achieve this through config.xml nowerdays. Citing from the wiki page linked above:

> This used to be a UI setting, but was removed in 2.119 as it did not > support migration of existing build records and could lead to > build-related errors until restart.

Solution 5 - Jenkins

I would suggest editing the /etc/default/jenkins

vi /etc/default/jenkins

And changing the $JENKINS_HOME variable (around line 23) to

JENKINS_HOME=/home/jenkins

Then restart the Jenkins with usual

/etc/init.d/jenkins start

Cheers!

Solution 6 - Jenkins

You can also edit the config.xml file in your JENKINS_HOME directory. Use c32hedge's response as a reference and set the workspace location to whatever you want between the tags

Solution 7 - Jenkins

By default, Jenkins stores all of its data in this directory on the file system.

There are a few ways to change the Jenkins home directory:

  • Edit the JENKINS_HOME variable in your Jenkins configuration file (e.g. /etc/sysconfig/jenkins on Red Hat Linux).
  • Use your web container's admin tool to set the JENKINS_HOME environment variable.
  • Set the environment variable JENKINS_HOME before launching your web container, or before launching Jenkins directly from the WAR file.
  • Set the JENKINS_HOME Java system property when launching your web container, or when launching Jenkins directly from the WAR file.
  • Modify web.xml in jenkins.war (or its expanded image in your web container). This is not recommended. This value cannot be changed while Jenkins is running. It is shown here to help you ensure that your configuration is taking effect.

Solution 8 - Jenkins

If you go into Configure under Home there is a "Help" note on how to:

Home directory /var/lib/jenkins Help for feature: Home directory

By default, Jenkins stores all of its data in this directory on the file system.

There are a few ways to change the Jenkins home directory:

Edit the JENKINS_HOME variable in your Jenkins configuration file (e.g. /etc/sysconfig/jenkins on Red Hat Linux).
Use your web container's admin tool to set the JENKINS_HOME environment variable.
Set the environment variable JENKINS_HOME before launching your web container, or before launching Jenkins directly from the WAR file.
Set the JENKINS_HOME Java system property when launching your web container, or when launching Jenkins directly from the WAR file.
Modify web.xml in jenkins.war (or its expanded image in your web container). This is not recommended. 

This value cannot be changed while Jenkins is running. It is shown here to help you ensure that your configuration is taking effect.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYaniv OferView Question on Stackoverflow
Solution 1 - JenkinsYaniv OferView Answer on Stackoverflow
Solution 2 - Jenkinsadil ameenView Answer on Stackoverflow
Solution 3 - Jenkinsc32hedgeView Answer on Stackoverflow
Solution 4 - JenkinsknorxView Answer on Stackoverflow
Solution 5 - JenkinsKathan ShahView Answer on Stackoverflow
Solution 6 - JenkinsArierView Answer on Stackoverflow
Solution 7 - JenkinsPravin BansalView Answer on Stackoverflow
Solution 8 - JenkinsJorduinoView Answer on Stackoverflow