如何更改jenkins主目录位置?

时间:2016-12-28 20:33:29

标签: jenkins

简单问题:如何更改jenkins主目录位置?默认情况下,它指向/ var / lib / jenkins,而我希望它指向/ mnt / home / jenkins。我已将$ JENKINS_HOME更改为/ mnt / home / jenkins,但它对我没有帮助。

我得到了詹金斯的Ui问题。见下面的错误。如果我留下相同的/ var / lib / jenkins /它工作正常。 HTTP错误:503

访问/的问题。原因是:

Service Unavailable

由Jetty提供://

2 个答案:

答案 0 :(得分:3)

如果您需要更改Ubuntu中的Jenkins主目录,请按照以下说明操作:

Stop Jenkins 
/etc/init.d/jenkins stop

Create folder for new Jenkins home directory
mkdir home

Change access rights for this folder and all folders and files inside
sudo chown -R jenkins:jenkins home

Find current Jenkins folder and copy all directories and files into new one. If you don't know current Jenkins directory you can find it in /etc/default/jenkins file.
sudo -u jenkins cp -r /var/lib/jenkins/* home/

Change JENNIKS_HOME inside /etc/default/jenkins
sudo nano /etc/default/jenkins

find JENKINS_HOME and change path to new Jenkins home folder

Start Jenkins 
/etc/init.d/jenkins start 

In case if you have the error message 
Unable to create the home directory ‘/path/to/jenkins/home’. This is most likely a permission problem.
run the command
sudo chown -R jenkins:jenkins root_folder/

To get the root_folder you need go to Jenkins home folder and run pwd. This will work in case if you want use other one hdd (not system) for Jenkins home .
$pwd
/media/path/to/jenkins/home

In my case the root_folder is media

这就是全部。享受!

来源:http://www.sofment.com/?q=node/25

答案 1 :(得分:1)

默认情况下,Jenkins home设置为〜/ .jenkins,但您可以通过以下方式之一更改此内容:

  • 设置" JENKINS_HOME"环境变量到新的主目录 在启动servlet容器之前。
  • 设置" JENKINS_HOME"系统属性到servlet容器。
  • 设置JNDI环境条目" JENKINS_HOME"到新目录。

请参阅jenkins的以下网址 https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins