After installing jenkins with tomcat manage jenkins is not showing - jenkins

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.

Related

Getting error while running jenkins war in command prompt

I have installed jdk 8 and set path in system variable.
I am getting below error and might be because of that not getting user password to login to local host.
my error are below:
Error injecting constructor, java.lang.NoClassDefFoundError: hudson/tools/JDK
Installer$FileSystem
at hudson.os.windows.ManagedWindowsServiceLauncher$DescriptorImpl.<init>(Manag
edWindowsServiceLauncher.java:540)
and
Error injecting constructor, java.lang.NoClassDefFoundError: hudson/tools/JDK
Installer$FileSystem
at hudson.plugins.sshslaves.SSHLauncher$DescriptorImpl.<init>(SSHLauncher.java
:1550)
please help to resolve.
To run the Jenkins WAR from the commandline you would execute
java -jar jenkins.war
This will cause the war file to explode itself to a war directory and as Jenkins includes a JETTY web server it will "self host" at localhost:8080. It will take a couple of minutes to do this. Jenkins will present the new instance wizard screens for you to go through which will install recommended plugins to get going.
Initially you won't have to log into Jenkins as "Anyone can do anything".
The next steps should be:
If you are running on windows, navigate to Manage Jenkins > Install as Windows Service and specify a Jenkins Home directory (Suggest E:\Jenkins or on a secondary partition or C:\Jenkins). The user doing this will need to be an administrator on the machine for this to work.
Install plugins at Manage Jenkins > Manage Plugins
Set up Security at Manage Jenkins > Configure Security

How to move from Jenkins as service to Jenkins as application?

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

How to debug the Jenkins plugin

I have built a new "Hello World" plugin for Jenkins and I was able to upload it onto Jenkins and it works successfully. I am now trying to make change to the plugin and debug it on Jenkins.
Note:
My Jenkins is deployed in my local tomcat, i build the hpi file and copy it to jenkins plugins folder, it works.
Now i want to ask how can i debug my plugin code? Suggestions with any IDE is welcome.
I also have questions about:
do i need to create a project for jenkins source in my IDE and develop my plugin base on it?
Currently i only create a project for the plugin, build a hpi file and put it to Jenkins.
I am not sure if this step is correct.
Thanks in advance!
I imagine you ran
mvn package
to create your package
To debug you can do
mvnDebug hpi:run
and this will copy all the dependencies down (rather than in your jenkins install) and run it in place
If you are using an IDE then this can be done from within it.
More help can be found in the plugin tutorial
Follow the tutorial to set MAVEN_OPTS, and using IntelliJ to add a Jetty Server to point the port to it.
execute from cmd:
mvn clean
set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
mvn hpi:run
add a debug local Jetty Server from intelliJ and point it to port 8000 (port number is specified in above cmd)
In case of IntelliJ IDEA the easiest way is to use maven's Run/Debug configuration.
Just add hpi:run in "Command line" filed and start Debug as usual.
When the console says that your "Jenkins is fully up and running", open a browser and go to http://localhost:8080/jenkins/ and your code will stopped at break point (if any).

Jenkins losing configuration

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

How to change home directory of Jenkins?

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*

Resources