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

前端 未结 8 1822
野趣味
野趣味 2020-11-29 05:35

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?

相关标签:
8条回答
  • 2020-11-29 06:23

    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>
    
    0 讨论(0)
  • 2020-11-29 06:25

    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.

    0 讨论(0)
  • 2020-11-29 06:28

    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

    0 讨论(0)
  • 2020-11-29 06:28

    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!

    0 讨论(0)
  • 2020-11-29 06:30

    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.

    0 讨论(0)
  • 2020-11-29 06:32

    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:
    3. Now the fields for Workspace Root Directory and Build Record Root Directory appear:
    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.

    0 讨论(0)
提交回复
热议问题