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 :)
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.
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.
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.
I think this can help you out.
Set an Environment Variable JENKINS_HOME
pointing to the .jenkins
folder and run the Jenkins command.
export JENKINS_HOME=/usr/jhon/.jenkins
java -jar jenkins.war
SET JENKINS_HOME=C:\users\jhon\.jenkins
java -jar jenkins.war
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'
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With