I downloaded the jenkins war and su into the jenkins user and ran the following command
java -jar jenkins.war
I setup the configuration and when I rebooted the computer and loaded it up, all the configuration was gone. I checked the /home/jenkins/.jenkins and all the directories appear to be there. Looking at the system info section in jenkins I see the home directory set right
HOME /home/jenkins
Thoughts?
Ok I figured it out. I just had to as the jenkins user export the JENKINS_HOME variable and that did it
Related
The jenkins version is :
<version>2.186</version>
<installStateName>RESTART</installStateName>
<numExecutors>2</numExecutors>
<mode>NORMAL</mode>
All jobs disapperad after restart jenkins : sudo service jenkins restart
/var/lib/jenkins/config.xml includes them. The config file has no conflict. I have checked it using an xml validator.
How can I fix it? There is no job in jenkins dashboard.
Either option will work
1)
choose option reload configurations from disk (Manage Jenkins/Reload Configuration from Disk).
Or
2) Can you try to install Stable Jenkins and import all jobs n folder structure to new jenkins folder structure.
Hope that might help if by mistakenly someting is courupted or deleted in current folder structure of jenkins.
I had same issue I solved it using above method
I would first check folder permissions:
stat /var/lib/jenkins/jobs
stat /var/lib/jenkins
Then I would change permissions if needed:
chown -R your_user /var/lib/jenkins
You will need to restart Jenkins and maybe reboot the machine.
Running Jenkins 2.46.3 as a Windows service (Windows Server 2012 R2) does not allow me to interact with desktop applications. I've tried to fix this but it did not work for me (by changing registry settings), so I would like to run Jenkins as an application.
The problem is that when I run command: "C:\Program Files (x86)\Jenkins\jre\bin\java.exe" -jar jenkins.war Jenkins is extracted to C:\Users\Administrator\.jenkins folder and I have to setup it from the begining.
I don't want to setup it from the begining, I would like to run current installation as an application from the same folder it has been installed. How can I do this?
You need to tell where your Jenkins home directory is located. You can see your current Jenkins home directory in Manage Jenkins -> Configure System -> Home directory. (e.g C:\Program Files (x86)\Jenkins)
Then create a new environment variable called JENKINS_HOME to your Jenkins home directory (e.g C:\Program Files (x86)\Jenkins).
Stop your Jenkins instance, close your current command interpreter and start a new one, and launch Jenkins with your command (C:\Program Files (x86)\Jenkins\jre\bin\java.exe" -jar jenkins.war).
I am new to jenkins I know how to run build on jenkins from remote .When I was trying to configure in my local I followed the steps as below
1) Downloaded apache-tomcat-7.0.62
2) Downloaded jenkins.war [Jenkins ver. 1.651.2]
3) Copied jenkins.war and placed inside tomcat/webapps
4) Started the server
5) After starting it deployed jenkins folder inside the webapps
6) Pointed the JENKINS_HOME env varibale to this folder.
I am able to see the dashboard on my borwser after the starting the server
http://127.0.0.1:8080/jenkins/
But I am not getting any options like Manage Jenkins to customize anything.
Attached the screen shot for your reference.I tried with admin admin credentials but it didn't worked .What is the default credentials for this?.
and if any plugins I am missing please let me know.
Faced same problem today. It seems that you deleted, or it was not created - JENKINS_HOME folder, it should be placed in user\.jenkins.
At first check it - if there is really none, run the following command in folder with your jenkins.war, but stop tomcat first:
java -jar jenkins.war
After executing this command, go to http://localhost:8080 , it should run jenkins now not as tomcat part. Now you can create first admin user by follow instuctions.
When user was created, stop jenkins and run tomcat again, you will be able to login with created admin user in your tomcat/jenkins.
In any answer and in jenkins website tell me to set
<useSecurity>true</useSecurity>
in config.xml but in my jenkins folder don't have this file
config.xml doesn't get written until server is restarted at least once since installation.
Try restarting the Jenkins server.
This likely sounds like invalid Jenkins installation, or the file is in another place pointed by $JENKINS_HOME or $CATALINA_OPTS (e.g. ~/.jenkins or /var/usr/jenkins/.jenkins).
Another reason could be that by default Jenkins load all data from memory and you need to reload the configuration files from file system, so try restarting Jenkins.
Then double check in System Properties (at /systemInfo) that user.home points to the folder where you expect that file. Check also your System Log (/log/all) for any issues.
If above won't help, check the folder permission and if there is enough space (but you should have some error anyway). Or try reinstalling Jenkins.
According to Administering Jenkins documentation page, the config.xml Jenkins root configuration should be always in your JENKINS_HOME folder.
Once you've got config.xml, to disable security remove the lines with useSecurity and authorizationStrategy and restart Jenkins, or try executing these commands:
sudo ex +g/useSecurity/d +g/authorizationStrategy/d -scwq /var/lib/jenkins/config.xml
sudo /etc/init.d/jenkins restart
Simple question: How to change the jenkins home directory location? By default it points to /var/lib/jenkins whereas I want it to point to /home/jenkins. I have changed my $JENKINS_HOME to /home/jenkins but it doesn't help me.
For me on Jenkins 2.7.2 on RHEL 7.2 after already starting jenkins and configuring a build, I needed to:
1) Change the jenkins user's home directory
sudo su -
service jenkins stop
vi /etc/passwd
# change the /var/lib/jenkins to /home/jenkins or whatever
2) Change the setting in the start script to also find it
vi /etc/sysconfig/jenkins
# change the JENKINS_HOME to /home/jenkins or what ever
3) Copy all the data to the new location (eg: /home/jenkins)
cd /home
cp -Rf /var/lib/jenkins .
chown -R jenkins:jenkins *
4) Start it back up
service jenkins start
And that seems to have done it for me.
To change the Jenkins home directory you just need to setup the "JENKINS_HOME" environment variable to point to the new location. You can also set the JENKINS_HOME as a system property or a JNDI environment entry as explained in the documentation.
Jenkins Documentation
Jenkins usually runs with its own user,
so changing the home-dir of that user should do the job.
If not sure, simply run a test-job with a shell-command like 'id' or 'whoami' or 'env' to find the user that Jenkins uses.
Also, note that a message of "Started by user anonymous" does not mean that Jenkins started as an anonymous user -
please see this related answers by Sagar and Peter Tran:
how to run jenkins as a different user
I am using Ubuntu server and using Jenkins version (2.277.4 +). I was able to change the Jenkins home directory by:
Changing the JENKINS_HOME value in /etc/default/jenkins to the desired folder name.
Update permission on the target folder so that jenkins user has read,write,execute permissions on the folder.
I tried setting the PATH thing but it doesn't seem to work as it probably has to be under Jenkins user which does not have a real unix user account. I found the variable also accessible in /etc/sysconfig/jenkins which did the trick when I restarted 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. (In windows , ctrl + c / v . In Unix ,
use cp command) . Instead of moving, copy step is advised to keep one backup. Later we 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.
Follow steps:
sudo su
service jenkins stop
nano /etc/default/jenkins
change JENKINS_HOME variable to whatever folder you want
save it
service jenkins start*