How can I point Jenkins to another .jenkins home d

2020-02-23 06:55发布

I have the working /.jenkins folder under a specific user in home on Linux. I want to start Jenkins with another user, but re-use the .jenkins folder of the other user. How can I do this? Jenkins offers some instructions but I don't get it :)

标签: jenkins
7条回答
Luminary・发光体
2楼-- · 2020-02-23 07:35

I think this can help you out.

Set an Environment Variable JENKINS_HOME pointing to the .jenkins folder and run the Jenkins command.


The shell should be like

export JENKINS_HOME=/usr/jhon/.jenkins

java -jar jenkins.war


The batch should be like

  SET JENKINS_HOME=C:\users\jhon\.jenkins

 java -jar jenkins.war


The Powershell should be like

[Environment]::SetEnvironmentVariable("JENKINS_HOME", "${PWD}\.jenkins")
java -jar jenkins.war

This will set your home directory to the current-working-directory + './jenkins'

查看更多
欢心
3楼-- · 2020-02-23 07:36

In Tomcat 5 you can modify tomcat.conf and add the path:

export JAVA_OPTS="-DJENKINS_HOME=/home/jenkins"

Restart Jenkins.

查看更多
Emotional °昔
4楼-- · 2020-02-23 07:40

I am using jenkins 1.639 as a war deployed on tomcat 7.0.67 . My JENKINS_HOME is set to /home/hims/jenkins

This is the entry of my setenv.sh file under /tomcat/bin directory

export CATALINA_OPTS="-DJENKINS_HOME=/home/hims/jenkins"

I hope this helps.

查看更多
家丑人穷心不美
5楼-- · 2020-02-23 07:43

Here are the options you have:

a) Assuming you're deploying Jenkins into Tomcat,you can do the following:

In your catalina.home/conf/localhost/jenkins.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/home/enomad/projects/jenkins/jenkins-master/war/target/jenkins" path="" reloadable="true">
 <Environment name="JENKINS_HOME" value="/home/enomad/projects/jenkins-home"
         type="java.lang.String" override="false"/>
</Context>

b) You can export the JENKINS_HOME=toWhateveryouwant as mentioned by Harsha in the previous post

c) You can extend your JAVA_OPTS params and add -DJENKINS_HOME=/path/to/jenkins_home/ as described here: Jenkins Mailing list

Good luck!

查看更多
男人必须洒脱
6楼-- · 2020-02-23 07:47

Usually, you need to set the permissions for those files to be accessed by the new user.

See here: How to run jenkins as a different user -
especially the answers of Sagar and Peter Tran .

Cheers

查看更多
干净又极端
7楼-- · 2020-02-23 07:48

Or you can modify the .bashrc so that it sets the environment variable everytime you start a console, that is, if you are using bash to start Jenkins.

查看更多
登录 后发表回答