Change JENKINS_HOME on Red Hat Linux?

后端 未结 7 937
闹比i
闹比i 2021-02-01 16:47

I used this procedure to install Jenkins:

https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+RedHat+distributions

After it was up and running I

7条回答
  •  孤街浪徒
    2021-02-01 17:13

    I have faced the same issue and question. Connecting some dots I could fix my Jenkins after I moved Jenkins to a new location due to the same issue -space in disk under /var/lib/jenkins.

    Here is the procedures that I had to follow to get it working taking in consideration that I am pointing Jenkins to a non-default port. (I have applied this process into 2 servers)

    First, move the Jenkins directory from /var/lib/jenkins to /opt/jenkins

    sudo service jenkins stop
    sudo mv /var/lib/jenkins /opt/
    

    Now you can change your workspace and build directory to any other location on your machine. Jenkins provides 3 predefined variables that can be used to specify the new location:

    JENKINS_HOME — Jenkins home directory

    ITEM_ROOTDIR — Root directory of a job for which the workspace is allocated

    ITEM_FULLNAME — ‘/’-separated job name, like “foo/bar”

    sudo su jenkins (access as Jenkins user)
    JENKINS_HOME=/opt/jenkins
    ITEM_ROOTDIR=/opt/jenkins
    ITEM_FULLNAME=/opt/jenkins
    exit (exit Jenkins user)
    

    Now, edit the jenkins config

    /opt/jenkins$ sudo nano /etc/default/jenkins
    

    Modify the following line

    #jenkins home location
    #JENKINS_HOME=/var/lib/$NAME (here is the default)
    JENKINS_HOME=/opt/jenkins (that is our new location)
    

    change the home directory of a user

    sudo usermod -d /opt/jenkins/ jenkins
    sudo service jenkins start
    

提交回复
热议问题