Related
I'm trying to follow the directions here: https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Apache to set up my Jenkins server to appear at http://myhost/jenkins. It works, but the Jenkins website thinks http://myhost/ is the jenkins/ root.
I believe this problem is caused by the first warning flag on that web page, i.e. that my context path is not set correctly. However, I can't figure out where to set the context path. The instructions for ubuntu and windows are clear enough, but on Mac OS X 10.6, there is no jenkins.xml file, no /etc/default/jenkins file, and nothing of relevance I can see in ~/.jenkins/config.xml.
So, what am I missing? Where can I tell jenkins that its root is in /jenkins/ instead of /?
Paraphrasing from the document you mentioned;
You need to specify the context/prefix of the Jenkins instance, this can be done by modifying the Jenkins configuration as follows;
Either, set the context path by modifying the jenkins.xml configuration file and adding --prefix=/jenkins (or similar) to the entry.
Or Set the context path when using by adding --prefix=/jenkins to JENKINS_ARGS in /etc/default/jenkins (Ubuntu) or in an appropriate startup file.
So, how to find these things...
The Jenkins.xml file should be in the $JENKINS_HOME directory, I'm not sure if Mac OS has the "updatedb" and "locate " commands, but you could try doing updatedb && locate jenkins.xml
Also, have a look in the startup scripts; /etc/init.d if installed from a package, or add the JENKINS_ARGS to the environment properties for the User running Jenkins (append to ~user/.profile) or the arguments for the container running Jenkins.
Be aware that if your Jenkins installation (without the prefix argument) was running under:
http://myserver:8080/ => 200 Jenkins is here
adding --prefix=/ci/dashboard in the arguments will produce this behaviour:
http://myserver:8080/ => 404
http://myserver:8080/ci/dashboard => 200 Jenkins is now here
Not sure where to look in config.xml, but at http://myhost/jenkins/configure, there's an option called "Jenkins URL" that you can use to set that.
Just to provide some recent confirmation of the suggested approaches, on CentOS 7, with Jenkins 1.610, I was able to achieve this by changing jenkinsUrl in jenkins.model.JenkinsLocationConfiguration.xml to the desired one (e.g. http://127.0.0.1:8080/jenkins), adding
JENKINS_ARGS="--prefix=/jenkins"
inside /etc/sysconfig/jenkins, and restarting Jenkins.
FYI the Jenkins installation was made via Puppet, using this Puppet module.
Add prefix attribute to /etc/default/jenkins file:
JENKINS_ARGS="--webroot=/var/cache/jenkins/war --prefix=/jenkins --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT
Configure your web server (e.g. - nginx) to redirect /jenkins to localhost:8080;
Put this into /etc/apache2/other/jenkins.conf:
ProxyPass /jenkins http://localhost:8009/jenkins
ProxyPassReverse /jenkins http://localhost:8009/jenkins
ProxyRequests Off
<Proxy http://localhost:8009/jenkins*>
Order deny,allow
Allow from 127.0.0.1
</Proxy>
Then execute these commands:
sudo defaults write /Library/Preferences/org.jenkins-ci httpPort 8009
sudo defaults write /Library/Preferences/org.jenkins-ci prefix /jenkins
sudo launchctl stop org.jenkins-ci
The last command tells launchd to stop the running instance of Jenkins. And a new one will automatically be started because the launchd has been configured to always keep Jenkins running.
This is how I fixed it under Debian Wheezy running Jenkin 1.557
in /etc/default/jenkins , modify the JENKINS_ARGS line by adding "--prefix=$PREFIX"
JENKINS_ARGS=" ..... --prefix=$PREFIX"
you need to edit jenkins config file in directory
such like :
sudo vi /etc/default/jenkins and change var HTTP_PORT
next restart jenkins
sudo /etc/init.d/jenkins restart
hope this is helpful
I'm using CentOS7, add JENKINS_ARGS="--prefix=/jenkins" to /etc/sysconfig/jenkins and restart Jenkins worked. Then you can visit via ip:8080/jenkins
I'm not sure if people are still looking for this, but as I just ran across it, I figured I'd post my solution here.
By following the instructions at here, I was able to set the context located in Library/Preferences/org.jenkins-ci.plist to a more preferable address. The link has all the settings you can edit with an OS X native install.
I needed to configure Jenkins on a CentOS box via Puppet using the rtyler/jenkins module. Looking through the module code might suggest that HTTP_PORT and PREFIX should be the parameters in the config_hash but this did not work for me. What worked for me was something like the following Puppet configuration:
class { 'jenkins':
config_hash => {
'JENKINS_PORT' => { 'value' => '8085' },
'JENKINS_ARGS' => { 'value' => '--prefix=/jenkins' },
},
}
I was able to confirm that this updated the contents of "/etc/sysconfig/jenkins" (I believe this is the CentOS/RedHat file location).
For a Windows installation add the prefix within the <arguments> tag (jenkins.xml) and restart the service (Powershell Restart-Service jenkins). E.g.:
<executable>%BASE%\jre\bin\java</executable>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war" --prefix=/jenkins</arguments>
I am installing Jenkins 2 on windows,after installing,a page is opened,URL is:
http://localhost:8080/login?from=%2F
content of the page is like this:
Question:
How to "Unlock Jenkins"?
PS:I have looked for the answer in documentation and google.
Starting from version 2.0 of Jenkins you may use
-Djenkins.install.runSetupWizard=false
to prevent this screen.
Accroding to documentation
jenkins.install.runSetupWizard - Set to false to skip install wizard. Note that this leaves Jenkins unsecured by default.
Development-mode only: Set to true to not skip showing the setup wizard during Jenkins development.
More details about Jenkins properties can be found on this Jenkins Wiki page.
Check https://wiki.jenkins-ci.org/display/JENKINS/Logging to see where Jenkins is logging its files.
e.g. for Linux, use the command: less /var/log/jenkins/jenkins.log
And scroll down to the part: "Jenkins initial setup is required. An admin user has been created ... to proceed to installation:
[randompasswordhere] <--- Copy and paste
Linux
By default logs should be made available in /var/log/jenkins/jenkins.log, unless customized in /etc/default/jenkins (for *.deb) or via /etc/sysconfig/jenkins (for */rpm)
Windows
By default logs should be at %JENKINS_HOME%/jenkins.out and %JENKINS_HOME%/jenkins.err, unless customized in %JENKINS_HOME%/jenkins.xml
Mac OS X
Log files should be at /var/log/jenkins/jenkins.log, unless customized in org.jenkins-ci.plist
open file: e:\Program Files (x86)\Jenkins\secrets\initialAdminPassword
copy content file: 47c5d4f760014e54a6bffc27bd95c077
paste in input: http://localhost:8080/login?from=%2F
DONE
Some of the above instructions seem to have gone out of date. As of the released version 2.0, creating the following file will cause Jenkins to skip the unlock screen:
${JENKINS_HOME}/jenkins.install.InstallUtil.lastExecVersion
This file must contain the string 2.0 without any line terminators. I'm not sure if this is required but Jenkins also sets the owner/group to be the same as the Jenkins server, so that's probably a good thing to mimic as well.
I did not need to create the upgraded or .last_exec_version files.
I assume you were running jenkins.war manually with java -jar jenkins.war, then all logging information by default is output to standard out, just type the token to unlock jenkins2.0.
If you were not running jenkins with java -jar jenkins.war, then you can always follow this Official Document to find the correct log location.
Open your terminal and type code below to find all the containers.
docker container list -a
You will find jenkinsci/blueocean and/or docker:dind if not than
docker container run --name jenkins-docker --rm --detach ^
--privileged --network jenkins --network-alias docker ^
--env DOCKER_TLS_CERTDIR=/certs ^
--volume jenkins-docker-certs:/certs/client ^
--volume jenkins-data:/var/jenkins_home ^
--volume "%HOMEDRIVE%%HOMEPATH%":/home ^
docker:dind
and
docker container run --name jenkins-blueocean --rm --detach ^
--network jenkins --env DOCKER_HOST=tcp://docker:2376 ^
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 ^
--volume jenkins-data:/var/jenkins_home ^
--volume jenkins-docker-certs:/certs/client:ro ^
--volume "%HOMEDRIVE%%HOMEPATH%":/home ^
--publish 8080:8080 --publish 50000:50000 jenkinsci/blueocean
run command
docker run jenkinsci/blueocean
or
docker run docker:dind
Copy and Paste the secret key.
One method to prevent the installation wizard is to do the following in $JENKINS_HOME:
Create an empty file named .last_exec_version
Create a file named upgraded
If left empty, a banner will prompt you to "upgrade" to 2.0 (which just means install a bunch of new plugins like Pipeline)
If the contents of that file is 2.0, you'll receive no banner and it will act like an regular old Jenkins install
Remember, this wizard is in place to prevent unauthorized access to Jenkins during setup. However, bypassing this wizard can be useful if, for example, you want to deploy automated installations of Jenkins with something like Ansible/Puppet/etc.
This was tested against Jenkins 2.0-beta-1 – so these instructions may not work in future beta or stable releases.
In the mac use:
sudo more /Users/Shared/Jenkins/Home/secrets/initialAdminPassword
I have seen a lot of response to the question, most of them were actually solution to it but they solve the problem when jenkins is actually run as a standalone CI without Application container using the command:
java -jar jenkins.war
But when running on Tomcat as it is the case in this scenario, Jenkins logs are displayed on the catalina logs since the software is running on a container.
So you need to go to the logs folder:
C:\Program Files\tomcat_folder\Tomcat 8.5\logs\catalina.log
in my own case. Just scroll almost to the middle to look for a generated password which is essentially a token and copy and paste it to unlock jenkins.
I hope this fix your problem.
Step 1: Open the terminal on your mac
Step 2: Concatenate or Paste
sudo cat **/Users/Shared/Jenkins/Home/secrets/initialAdminPassword**
Step 3: It will ask for password, type your mac password and enter
Step 4: A key would be generated.
Step 5: Copy and paste the security token in Jenkins
Step 6: Click continue
I found the token in the following file in the installation dir:
<jenkins install dir>\users\admin\config.xml
and the element
<jenkins.install.SetupWizard_-AuthenticationKey>
<key> THE KEY </key>
</jenkins.install.SetupWizard_-AuthenticationKey>
You might see it in the catalina.out. I installed Jenkins war in tomcat and I can see this in the catalina.out
The below method does not work anymore on 2.42.2
Create an empty file named .last_exec_version
Create a file named upgraded
If left empty, a banner will prompt you to "upgrade" to 2.0 (which just means install a bunch of new plugins like Pipeline)
If the contents of that file is 2.0, you'll receive no banner and it will act like an regular old Jenkins install
mostly jenkins will show you the path for initialAdminPassword if you dont find it there, then you have to check jenkins logs
in log you will see
05-May-2017 01:01:41.854 INFO [Jenkins initialization thread] jenkins.install.SetupWizard.init
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
7c249e4ed93c4596972f57e55f7ff32e
This may also be found at: /opt/tomcat/.jenkins/secrets/initialAdminPassword
Use a lil shortcut to get to the folder:
cmd + shift + g
then insert /Users/Shared/Jenkins
there u can see the secrets folder - probably shows that it's locked.
to unlock it: right click on the folder and click info + click on the lock at the bottom. now u can change the rights shown at the bottom of the window
hope that helped :)
Greetings, Stefanie ^__^
If unable to find Jenkins password in the location C:\Windows\System32\config\systemprofile\.jenkins\secrets\initialAdminPassword
by installing Jenkins generic war on Tomcat server, try below
Solution:
Set environmental variable JENKINS_HOME to your jenkins path say
JENKINS_HOME ="C:/users/username/apachetomcat/webapps/jenkins"
Place Jenkins.war in the webapp folder of Tomcat and start Tomcat,
initial admin password gets generated in the path
C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\jenkins\secrets\initialAdminPassword
Yet another way to bypass the unlock screen is to copy the UpgradeWizard state to the InstallUtil last execution version, add an install.runSetupWizard file with the contents 'false', and update the config.xml installStateName from NEW to RUNNING.
docker exec -it jenkins bash
sed -i s/NEW/RUNNING/ /var/jenkins_home/config.xml
echo 'false' > /var/jenkins_home/jenkins.install.runSetupWizard
cp /var/jenkins_home/jenkins.install.UpgradeWizard.state /var/jenkins_home/jenkins.install.InstallUtil.lastExecVersion
exit
docker restart jenkins
For reference, this is the command I use to run jenkins:
docker run --rm --name jenkins --network host -u root -d -v jenkins:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean:1.16.0
You will also want to update the config with the Root URL:
echo "<?xml version='1.1' encoding='UTF-8'?><jenkins.model.JenkinsLocationConfiguration><jenkinsUrl>http://<IP>:8080/</jenkinsUrl></jenkins.model.JenkinsLocationConfiguration>" > jenkins.model.JenkinsLocationConfiguration.xml
exit
docker restart jenkins
In case, if you installed/upgraded new versions of jenkins and unable to find admin credentials on server then, ...
if you are using old version of jenkins and on the top of it you are trying to reinstall/upgrade new version of jenkins then,
the files under "JENKINS_HOME", namely -
${JENKINS_HOME}/jenkins.install.InstallUtil.lastExecVersion
${JENKINS_HOME}/jenkins.install.UpgradeWizard.state
will cause jenkins to skip the unlock (or admin credentials screen) and webpage directly ask you for username and password. even on server you will not able to find "${JENKINS_HOME}/secrets/initialAdminPassword".
In such case, don't get panic. just try to use old admin user creds in newly installed/upgraded jenkins server.
In simple language, if you have admin creds as admin/admin in old version of jenkins server then, after upgrading jenkins server, the new server won't ask you set password for admin user again. in fact it will use old creds only.
I have found the password in C:\Program Files\Jenkins\jenkins.err. Open jenkins.err text file and scroll down, and you will find the password.
Go to C:\Program Files (x86)\Jenkins\secrets
then with notepad ++ open file initail Admin Password and paste its content.
thats it
-->if you are using linux machine, then login as root user: sudo su
-->then go to the below path: cd /var/lib/jenkins/secrets
-->just view the IntialAdminPassword file ,you can see the secret key.
-->paste the secret key into jenkins window,it will be unlocked.
https://issues.jenkins-ci.org/browse/JENKINS-35981
Try this %2Fjenkins%2F instead of %2Fjenkins in the browser
Open the terminal on your mac and open new window (command+T)
Paste sudo cat /Users/Shared/Jenkins/Home/secrets/initialAdminPassword
It will ask for password, type your password(i gave my mac password, i haven't check if any other password would work) and enter
A key would be generated.
Copy the key and paste it where it asks you to enter admin password
click continue
The problem can be fixed in latest version: mine is 2.4. The error comes because of %2fjenkins%2f in URL. The previous version was coming with %2fjenkins and the same error used to come. They have resolved the issue, but the URL has been changed from %2fjenkins to %2fjenkins%. So as a summary in the URL currently %2fjenkins% is coming. before passing the admin password change it to %2fjenkins. Along with that add a .last_exec_version empty file.
If someone chooses running Jenkins as a Docker container, may face the same problem with me.
Because accessing-the-jenkins-blue-ocean-docker-container is quite different,
Common problem is /var/lib/jenkins/secrets: No such file or directory
You need to access through Docker, the link Jenkins provide is quite helpful.
Except <docker-container-name> maybe not specified, then you may need to use the container ID.
After
docker exec -it jenkins-blueocean bash
or
docker exec -it YOUR_JENKINS_CONTAINER_ID bash
The /var/lib/jenkins/secrets/initialAdminPassword would be accessible.
The password would be there.
I have setup Jenkins using Brew, But when I restarted Mac Jenkins was asking for initialAdminPassword(The screenshot attached in question)
And the problem was it was not generated under sercret directory.
So I'd found the Jenkins process which was running on port: 8080 using: $ sudo lsof -i -n -P | grep TCP and killed it using $ sudo kill 66(66 was process id).
Then I downloaded the latest jenkins .war file from: https://jenkins.io/download/
And executed command: $ java -jar jenkins.war (Make sure you are in jenkins.war directory).
And that's it everything is working fine.
This works well when you are stuck with Docker on Windows and are using Git-Bash
Presuming something like:
# docker run --detach --publish 8080:8080 --volume jenkins_home:/var/jenkins_home --name jenkins jenkins/jenkins:lts
Execute to get the Container ID, for example "d56686cb700d"
# docker ps -l
Now tell Docker to return the password written in the logs for that Container ID:
# docker logs d56686cb700d 2>&1 | grep -A5 -B5 Admin
2>&1 redirects stderr to stdout
-A5 includes 5 lines AFTER the line with "Admin" in it
-B5 includes 5 lines BEFORE the line with "Admin" in it
Output example:
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
47647383733f4387a0d53c873334b707
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
I found it under below directory. Full issue detail https://github.com/jenkinsci/ibm-security-appscansource-scanner-plugin/issues/2
C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Jenkins\.jenkins
Open jenkins.err file in C:\Program Files\Jenkins\.
In that file check for a hash key after this line
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
And paste it there in the jenkins prompt. Worked for me.
To solve this problem for docker container in Ubuntu 18.04.5 LTS (Bionic Beaver) - Ubuntu Releases
1- connect to your docker server or ubuntu server witch ssh or other method
2- run sudo docker ps
3- copy the container name parameter ("NAMES")
4- run sudo docker logs "your_parameters_NAMES_VALUES"
5- Find the folowing sentence "Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:" and copy the password
I have latest Jenkins and it's Swarm plugin client jar (2.0).
I downloaded the swarm-client jar and I ran the following command to create the slave: (Note: : I'm using user Anonymous to connect to Jenkins master without requiring username/password and have provided Create Slave permission in Global Roles, and all access in Slave section under Slave roles by creating a new role with pattern swarm.*). Jenkins Swarm client: https://wiki.jenkins-ci.org/display/JENKINS/Swarm+Plugin
A user can provide a valid username/password if that user has Create Slave (Global Roles) and other access like connect, delete, etc in Slave Roles in Jenkins under Manage Roles).
$ which swarm-client.jar
~/tools/bin/swarm-client.jar
$ pwd
/home/confman/slaves
$ ~/tools/jdk1.7.0_60/bin/java -jar `which swarm-client.jar` -name "swarm_`hostname -a`" -fsroot "~/slaves/swarm_`hostname -a`" -master http://jenkins_master.srvr.company.com:8083 -username Anonymous -description "`hostname -a` " -executors 5 -labels "ANSIBLE_CENTOS CENTOS" -mode 'exclusive' -showHostName -t java=~/tools/jdk1.8.0_45 -t gradle=~/tools/gradle-2.3 -t Maven=~/tools/apache-maven-3.3.3 -t Groovy2=~/tools/groovy-2.4.5 --showHostName -retry 0 -disableClientsUniqueId &
But, instead of the above command setting Slave's Remote Root Directory to ~/slaves/swarm_jmeter01, it's setting the remote root path including the folder as prefix/relative to from where I ran the above command (as shown below). In my case, hostname command value is jmeter01.
The documentation doesn't mention that this paramter is relative to the current folder (where you'd run the java -jar slave-client jar command).
Has anyone found a solution for this i.e. it can ignore the current folder and set it to ~/slaves/swarm_01 or something like that?
Obviously In my automation to resolve this issue, I can first "cd" (change directory) to the correct folder ~/slaves and then just pass -fsroot "swarm_`hostname -a`" to get remote directory path value set as: ~/slaves/swarm_jmeter01 (in that case, it'll work fine).
~ is shell expansion ... if this not works, then use $HOME instead
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 discovered the /var/lib/jenkins partition on my server is very small. I want to move it, but I do not want to change the user that it runs under. I am new to Linux and I'm stumped. How do I move it for example to my Home/Public folder? The "Jenkins" user doesn't seem to have a Home folder. Its running as a daemon on startup, so I have no idea where to configure those settings.
Can I create a Home folder for the Jenkins user? How?
I read this article:
https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins
but do not understand HOW to "set the new Jenkins home". I have used the export command, and restarted the service, but the old path still shows up in the Manage Jenkins screens.
I've read the 2-3 similar questions on stackoverflow also, but there's always a big missing piece for me. Where to find that file where I change the path permanently?
Here's an easy way to solve your problem. First, move the Jenkins directory from /var/lib/jenkins to /home/jenkins. Then create a symlink at /var/lib/jenkins pointing to /home/jenkins. And of course, stop the Jenkins service before doing that.
sudo service jenkins stop
sudo mv /var/lib/jenkins /home
sudo ln -s /home/jenkins /var/lib/jenkins
sudo service jenkins start
I managed to change the home location for Jenkins by modifying content of /etc/sysconfig/jenkins file as follows:
JENKINS_HOME="/home/jenkins"
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.
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.
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.
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
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
I have faced the same issue and question.
Connecting some dots I could fix my Jenkins after I moved Jenkins to a new location due to the same issue -space in disk under /var/lib/jenkins.
Here is the procedures that I had to follow to get it working taking in consideration that I am pointing Jenkins to a non-default port. (I have applied this process into 2 servers)
First, move the Jenkins directory from /var/lib/jenkins to /opt/jenkins
sudo service jenkins stop
sudo mv /var/lib/jenkins /opt/
Now you can change your workspace and build directory to any other location on your machine.
Jenkins provides 3 predefined variables that can be used to specify the new location:
JENKINS_HOME — Jenkins home directory
ITEM_ROOTDIR — Root directory of a job for which the workspace is allocated
ITEM_FULLNAME — ‘/’-separated job name, like “foo/bar”
sudo su jenkins (access as Jenkins user)
JENKINS_HOME=/opt/jenkins
ITEM_ROOTDIR=/opt/jenkins
ITEM_FULLNAME=/opt/jenkins
exit (exit Jenkins user)
Now, edit the jenkins config
/opt/jenkins$ sudo nano /etc/default/jenkins
Modify the following line
#jenkins home location
#JENKINS_HOME=/var/lib/$NAME (here is the default)
JENKINS_HOME=/opt/jenkins (that is our new location)
change the home directory of a user
sudo usermod -d /opt/jenkins/ jenkins
sudo service jenkins start
If anyone is having issues with space and you have to relocate your jenkins, just wanted to reiterate that::
sudo service jenkins stop
sudo mv /var/lib/jenkins /home
sudo ln -s /home/jenkins /var/lib/jenkins
sudo service jenkins start
works great, so thanks to the person who posted that answer a few years ago!
Richard Chen's location is where I found the jenkins file on my CentOS 6.6 system.
sudo service jenkins stop
mv /var/lib/jenkins /home/mylocation/
(made sure the new location had correct ownership and group-- Jenkins)
modified the content of the file /etc/sysconfig/jenkins as follows:
JENKINS_HOME="/home/mylocation"
sudo service jenkins start
If all these don't work, then the only solution that works is to edit the following file
/lib/systemd/system/jenkins.service
then need to execute reloading of configs by running
systemctl daemon-reload
after this restarting the service would reflect the change.
Some commands work for me as below:
Step 1: Stop jenkin service and moving folder
systemctl stop jenkins
mv /var/lib/jenkins /whatever/folder
sudo chown jenkins -R /whatever/folder
Step 2: Modify jenkins home location in /etc/default/jenkins
JENKINS_HOME=/whatever/folder/$NAME
Step 3: Restart jenkins service
systemctl start jenkins
[A] Find your current jenkins home folder, if you are not aware where it is ?
Jenkins -> Manage Jenkins -> Configure System -> Check label 'Home directory'
[B] To move current Jenkins home folder to a new directory. Follow below steps :-
Stop Jenkins service - by killing the process
Follow one of below approach to set new home folder for JENKINS.
a) By default Jenkins home directory is set to ~/.jenkins
b) "JENKINS_HOME" environment variable setup in operating system.
c) "JENKINS_HOME" entry in JNDI environment.
d) "JENKINS_HOME" system property to the servlet container.
Tomcat context descriptor of the servlet, you can set below field in apache-tomcat-8.5.28/conf/context.xml :
<Context ...>
<Environment name="JENKINS_HOME" value="/path/to/jenkins_home/" type="java.lang.String"/>
</Context>
e) If jenkins.war file is deployed in a tomcat server , then even appending below content in bin/catalina.sh will setup JENKINS_HOME.
CATALINA_OPTS="-DJENKINS_HOME=/path_to/jenkins_home/"
Manually copy Jenkins home folder content from old to new home
folder. (use cp command) . Instead of moving, copy step is advised to keep one backup. Later you can delete old workspace.
Now start Jenkins, then It will pick the new home directory
from the path mentioned in JENKINS_HOME variable.
Note: - Just by setting above variable "JENKINS_HOME" to a different path will not copy
the files from current Jenkins home path to new one automatically. This copy step - you have to do it yourself, Manually.
I'm trying to follow the directions here: https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Apache to set up my Jenkins server to appear at http://myhost/jenkins. It works, but the Jenkins website thinks http://myhost/ is the jenkins/ root.
I believe this problem is caused by the first warning flag on that web page, i.e. that my context path is not set correctly. However, I can't figure out where to set the context path. The instructions for ubuntu and windows are clear enough, but on Mac OS X 10.6, there is no jenkins.xml file, no /etc/default/jenkins file, and nothing of relevance I can see in ~/.jenkins/config.xml.
So, what am I missing? Where can I tell jenkins that its root is in /jenkins/ instead of /?
Paraphrasing from the document you mentioned;
You need to specify the context/prefix of the Jenkins instance, this can be done by modifying the Jenkins configuration as follows;
Either, set the context path by modifying the jenkins.xml configuration file and adding --prefix=/jenkins (or similar) to the entry.
Or Set the context path when using by adding --prefix=/jenkins to JENKINS_ARGS in /etc/default/jenkins (Ubuntu) or in an appropriate startup file.
So, how to find these things...
The Jenkins.xml file should be in the $JENKINS_HOME directory, I'm not sure if Mac OS has the "updatedb" and "locate " commands, but you could try doing updatedb && locate jenkins.xml
Also, have a look in the startup scripts; /etc/init.d if installed from a package, or add the JENKINS_ARGS to the environment properties for the User running Jenkins (append to ~user/.profile) or the arguments for the container running Jenkins.
Be aware that if your Jenkins installation (without the prefix argument) was running under:
http://myserver:8080/ => 200 Jenkins is here
adding --prefix=/ci/dashboard in the arguments will produce this behaviour:
http://myserver:8080/ => 404
http://myserver:8080/ci/dashboard => 200 Jenkins is now here
Not sure where to look in config.xml, but at http://myhost/jenkins/configure, there's an option called "Jenkins URL" that you can use to set that.
Just to provide some recent confirmation of the suggested approaches, on CentOS 7, with Jenkins 1.610, I was able to achieve this by changing jenkinsUrl in jenkins.model.JenkinsLocationConfiguration.xml to the desired one (e.g. http://127.0.0.1:8080/jenkins), adding
JENKINS_ARGS="--prefix=/jenkins"
inside /etc/sysconfig/jenkins, and restarting Jenkins.
FYI the Jenkins installation was made via Puppet, using this Puppet module.
Add prefix attribute to /etc/default/jenkins file:
JENKINS_ARGS="--webroot=/var/cache/jenkins/war --prefix=/jenkins --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT
Configure your web server (e.g. - nginx) to redirect /jenkins to localhost:8080;
Put this into /etc/apache2/other/jenkins.conf:
ProxyPass /jenkins http://localhost:8009/jenkins
ProxyPassReverse /jenkins http://localhost:8009/jenkins
ProxyRequests Off
<Proxy http://localhost:8009/jenkins*>
Order deny,allow
Allow from 127.0.0.1
</Proxy>
Then execute these commands:
sudo defaults write /Library/Preferences/org.jenkins-ci httpPort 8009
sudo defaults write /Library/Preferences/org.jenkins-ci prefix /jenkins
sudo launchctl stop org.jenkins-ci
The last command tells launchd to stop the running instance of Jenkins. And a new one will automatically be started because the launchd has been configured to always keep Jenkins running.
This is how I fixed it under Debian Wheezy running Jenkin 1.557
in /etc/default/jenkins , modify the JENKINS_ARGS line by adding "--prefix=$PREFIX"
JENKINS_ARGS=" ..... --prefix=$PREFIX"
you need to edit jenkins config file in directory
such like :
sudo vi /etc/default/jenkins and change var HTTP_PORT
next restart jenkins
sudo /etc/init.d/jenkins restart
hope this is helpful
I'm using CentOS7, add JENKINS_ARGS="--prefix=/jenkins" to /etc/sysconfig/jenkins and restart Jenkins worked. Then you can visit via ip:8080/jenkins
I'm not sure if people are still looking for this, but as I just ran across it, I figured I'd post my solution here.
By following the instructions at here, I was able to set the context located in Library/Preferences/org.jenkins-ci.plist to a more preferable address. The link has all the settings you can edit with an OS X native install.
I needed to configure Jenkins on a CentOS box via Puppet using the rtyler/jenkins module. Looking through the module code might suggest that HTTP_PORT and PREFIX should be the parameters in the config_hash but this did not work for me. What worked for me was something like the following Puppet configuration:
class { 'jenkins':
config_hash => {
'JENKINS_PORT' => { 'value' => '8085' },
'JENKINS_ARGS' => { 'value' => '--prefix=/jenkins' },
},
}
I was able to confirm that this updated the contents of "/etc/sysconfig/jenkins" (I believe this is the CentOS/RedHat file location).
For a Windows installation add the prefix within the <arguments> tag (jenkins.xml) and restart the service (Powershell Restart-Service jenkins). E.g.:
<executable>%BASE%\jre\bin\java</executable>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war" --prefix=/jenkins</arguments>