Change JENKINS_HOME on Red Hat Linux?

后端 未结 7 938
闹比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 managed to change the home location for Jenkins by modifying content of /etc/sysconfig/jenkins file as follows:

    JENKINS_HOME="/home/jenkins"
    
    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2021-02-01 17:14

    Some commands work for me as below:

    Step 1: Stop jenkin service and moving folder

    systemctl stop jenkins
    mv /var/lib/jenkins /whatever/folder
    sudo chown jenkins -R /whatever/folder
    

    Step 2: Modify jenkins home location in /etc/default/jenkins

    JENKINS_HOME=/whatever/folder/$NAME
    

    Step 3: Restart jenkins service

    systemctl start jenkins
    
    0 讨论(0)
  • 2021-02-01 17:18

    Richard Chen's location is where I found the jenkins file on my CentOS 6.6 system.

    1. sudo service jenkins stop
    2. mv /var/lib/jenkins /home/mylocation/
    3. (made sure the new location had correct ownership and group-- Jenkins)
    4. modified the content of the file /etc/sysconfig/jenkins as follows:

      JENKINS_HOME="/home/mylocation"

    5. sudo service jenkins start
    0 讨论(0)
  • 2021-02-01 17:24

    Okay, I reread your question a little bit more closely, lets see if we can figure this out. I am going to list some info that you may or may not know.

    1. The jenkins installation and jenkins home are not the same thing. One is where the war file and other parts that jenkins needs to run live. jenkins_home is where your data is stored. By default, jenkins_home lives in ~/.jenkins. When you start jenkins, it looks for an environment variable to tell it where to find those files.

    2. Jenkins runs as a seperate user, which, by default, is jenkins. This way it doesn't get in the way of you. The jenkins user will not have access to YOUR home directory, so that would be a poor solution. Ideally, it would have its own home directory, /home/jenkins. Your home directory could then be /home/jenkins/.jenkins. You say that folder doesn't exist- if you don't have access to it to create it yourself, that is perfectly fine, you can specify ANY folder. However, the jenkins user must have ownership of that folder to read and write to it.

    3. It looks like Jenkins on redhat will be running with tomcat by default. The documentation for how to set environment variables for tomcat is https://wiki.jenkins-ci.org/display/JENKINS/Tomcat

    4. This all gets set up with a script.https://wiki.jenkins-ci.org/display/JENKINS/JenkinsLinuxStartupScript seems to be the one that is used for this purpose. Even if you don't know anything about shell scripting, this isn't too hard... lines with a # are comments. The first line

      JENKINS_USER=jenkins

    sets the name of the user account jenkins will be using. Look down a littlle further, and you'll see the line

    export JENKINS_BASEDIR=/home/jenkins
    
    export CATALINA_OPTS="-DJENKINS_HOME=$JENKINS_BASEDIR/jenkins-home -Xmx512m -Djava.awt.headless=true"
    

    This lets you set a directory to where jenkins should live, and then sets the jenkins_home directory to that /jenkins-home.

    For your application, you may want to do something like this

    export CATALINA_OPTS="-DJENKINS_HOME=/var/jenkinsmount/home -Xmx512m -Djava.awt.headless=true"
    

    That would then store all of your build data (which is the part that grows!) at /var/jenkinsmount/home ... while leaving the rest of your files in their current location.

    I haven't used it on redhat, but hopefully I explained enough for you to actually understand what is going on so that you can get it going!

    Other INFO:

    https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Unix+daemon

    0 讨论(0)
  • 2021-02-01 17:28

    Here's an easy way to solve your problem. First, move the Jenkins directory from /var/lib/jenkins to /home/jenkins. Then create a symlink at /var/lib/jenkins pointing to /home/jenkins. And of course, stop the Jenkins service before doing that.

    sudo service jenkins stop
    sudo mv /var/lib/jenkins /home
    sudo ln -s /home/jenkins /var/lib/jenkins
    sudo service jenkins start
    
    0 讨论(0)
提交回复
热议问题