Change JENKINS_HOME on Red Hat Linux?

后端 未结 7 1015
闹比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: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

提交回复
热议问题