Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I point Jenkins to another .jenkins home directory?

Tags:

jenkins

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 :)

like image 268
user1340582 Avatar asked Jan 03 '13 12:01

user1340582


People also ask

Can we change Jenkins home directory?

Change Jenkins Home on Windows The default Jenkins Home locations are used only if a JENKINS_HOME environment variable is not pre-configured. To change the location of Jenkins Home on Windows, simply add or update the JENKINS_HOME system variable and restart the CI/CD tool.

How do I change the default home directory in Jenkins?

To change the Jenkins Home directory on Linux, create a new Home directory, copy the contents of the old Home directory to the new one and edit the Jenkins configuration file.

Which of the following things are available in Jenkins home directory?

The Jenkins home directory contains all the details of your Jenkins server configuration, details that you configure in the Manage Jenkins screen. These configuration details are stored in the form of a set of XML files.


2 Answers

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'

like image 168
Harshavardhan Konakanchi Avatar answered Sep 25 '22 01:09

Harshavardhan Konakanchi


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!

like image 29
atlasloewenherz Avatar answered Sep 23 '22 01:09

atlasloewenherz