Jenkins service starts then stops on Windows 7 - jenkins

I downloaded the native windows Jenkins package and installed it. On installation, it starts as a service in and shows in Task Manager, and also on going to the url localhost:8080. But then it stops. Here is what I get in my jenkins.out.log:
Running from: C:\Program Files (x86)\Jenkins\jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
Jenkins home directory: C:\Program Files (x86)\Jenkins found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
Any ideas what could be causing this? I've checked throuh netstat that no other process is using the port 8080.

I found that the java.exe process was hung and keeping Jenkins from starting. I killed the java process and then jenkins service started up just fine.
Use process explorer.

It's possible to start jenkins via the command line using java -jar jenkins.war, however, because the process is started via the command line it will also end when that command window is closed.
A better way would be to start the service via jenkins.exe but you would have to remind doing that at every startup.
Ultimately we have settled with a batch script with the following content:
cd "C:\Program Files (x86)\Jenkins"
start javaw -jar jenkins.war >> outputFile.txt
adding start before calling javaw makes sure that the command window is not attached to the process started, making it possible to safely close down the command line.
Using >> outputFile.txt writes the command window feedback in a text file, making debugging a whole lot easier when Jenkins ever breaks down!
Save it in a batch script, schedule it with windows Task Scheduler to run at startup et voilà: properly set up Jenkins service.
Only make sure it doesn't stop at log-off.

I switched back to version 1.535 and now it works.

After my win vm system rebooted, the jenkins 1.625.2 service would just keep stopping.
It solved it by:
Kill java processes. Found some old java running dll's.
Uninstall old version of jdk1.6 that was there.
Cleaning java temp. files dir.
Then I was able to restart the service w/o problem.

if java.exe not visible in process
1.netstat -a -o -n find out the PID of your port
2.tasklist /FI “PID eq PID″
3.taskkill /F /PID 2600 kill the process

Related

How to stop Appium server programmatically and automated in Jenkins Pipeline

Appium server sometimes it does not stop when you try to close it, server and port is still hanging forever and the Appium CLI has no build-in command to stop the server which makes it harder to manage programmatically
Imagine that you want to manage it programmatically with the automation process in your CI/CD pipeline
such as Jenkins it could be a really painful story
appium
or
appium & (as background process)
The command to start Appium server that can be stopped only when you terminate it but sometimes it not stop
I've searched for the answer on StackOverflow for a long time and none of them answer directly to my question
So far what seems to work is that you have to kill the process of the server manually in the shell with the specific process id
To make it simply work with the pipeline, we could have a short version of the command
kill $(lsof -t -i :4723)
kill \$(lsof -t -i :${APPIUM_PORT}) [In Jenkinsfile]
Where the APPIUM_PORT is your Appium port, the default port is 4723
lsof command should work in Unix-like systems e.g. MacOS, Linux
lsof is a command meaning "list open files", which is used in many
Unix-like systems to report a list of all open files and the processes
that opened them
By running this command it should return an ID of the process running on that specific port to use for the kill signal
To implement in the pipeline
Add this step at the end of your Jenkinsfile
post{
always{
...
echo "Stop appium server"
sh "kill \$(lsof -t -i :${APPIUM_PORT})"
}
success{
...
}
failure{
...
}
cleanup{
...
}
}
It should kill the hanging Appium server process and you can start the new Appium server again with the same port!
To see more details on this I already publish a blog here
How to start/stop Appium server in Jenkins Pipeline
Hope it helps

Jenkins process gets killed when I close the putty session of ec2 instance

I am running jenkins on ec2 instance and my process gets killed when I close the putty session.Is there anyway I could run jenkins even after closing the session?
I run jenkins with
java -jar jenkins.war &
Any help would be appreciated.
Try putting a "nohup" in front of it, like so.
nohup java -jar jenkins.war &
Edit: To add to that, what you should really do is add it as a service in a supported way for the OS you're running, so that it starts when the instance is booted.

Jenkins_"Please wait while Jenkins is restarting" , quite a persistent one

I am getting the "Please wait while Jenkins is restarting" issue , I have restarted the Jenkins service but it still isn't working , I tried to install a plugin yesterday and since then it's showing me that message.
Any help would be much appreciated.
The simplest thing which will work almost every time is:
Login to the (windows) server where Jenkins is hosted.
Open CMD Prompt as administrator.
Go to path where jenkins.exe file is placed.
Enter command: jenkins.exe stop and then jenkins.exe start
For Linux server, kill the process and restart again.

Jenkins won't start after plugin installation *and does not log anything*

I installed Jenkins' Gradle plugin and used the automatic restart option via the Jenkins web interface. Jenkins seemed to hang on the "restarting..." page, so I finally tried to manually restart the Jenkins service on the server (64-bit Debian 7) using service jenkins restart.
Now, Jenkins is no longer running at all (verified with ps -ef | grep -i [J]enkins and service jenkins status), and when I try service jenkins [re]start, I see an [ ok ] message but nothing else seems to happen. I've deleted /var/log/jenkins/jenkins.log, and each time I try a service start (or restart), the log file reappears, but it's blank (ls -lA shows that the file was recently made, but cat produces no output). I also tried rebooting the server, with no effect. I finally deleted the Gradle folders under /var/lib/jenkins/plugins, which also did not appear to make a difference.
How do I even begin to approach this problem? Should I just re-install Jenkins?
EDIT: System info:
> uname -a
Linux AUC-Workstation1 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u1 x86_64 GNU/Linux
According to dpkg -l, I'm using Debian's jenkins package, version 1.617.
EDIT 2: I'm actually using the jenkins package provided directly by Jenkins, as per the instructions here.
I just had a problem where multiple Jenkins plugins were breaking Jenkins startup (after an upgrade) and here is the procedure I followed to resolve the issue, which might work for other plugin startup issues.
I'm working on an Ubuntu server, but I expect that this would work for Debian if it's going to work at all - I encourage others to adjust the procedure:
logged into the server and switched to the jenkins user (sudo su jenkins in my case)
went to the main jenkins directory
renamed plugins to plugins.problems_YYYYMMDD
previously, I attempted to disable the plugins, but this did not work for me (system still would not start)
created an empty directory plugins
restarted jenkins (sudo service jenkins restart)
In my case, this started just fine
iteratively followed the following procedure to add plugins back in
copied 1 or more plugins from plugins.problems_YYYYMMDD/ to plugins/
restarted jenkins
went to the plugin center and installed updates as available
sometimes I needed to install updates in a particular order due to dependencies
evaluated results in 'Manage Old Data'
I think I'm facing some manual updates of the old data
Note: if you know which plugins are likely the problem, then it is easier to just disable or temporarily (re)move them rather than (re)moving all of the plugins!
I never did figure out the initial problem, but I did get Jenkins working again, sort of.
I uninstalled Jenkins (using apt-get purge) and then re-installed it. This time it failed to start because it needed Java 7, but I apparently only had Java 6 installed (this surprised me, because I thought I had previously configured Jenkins to use Java 7 on that machine). So I installed openjdk-7-jdk and openjdk-7-jre, set JAVA and JAVA_HOME appropriately in the Jenkins config file, and started the service again. This allowed Jenkins to start.

Start jenkins in the background

I'm using .war file to run jenkins on my server. They say use
java -jar jenkins.war
(Source: https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins)
to start the server. This starts the server and shows log on screen and it is ready to use.
The only problem is when I "ctrl+c" it stops the server. I want that it should start in the background so that even though I exit from putty it should be running. I know if use native package ".deb" it will be installed as service but I want to do it using only ".war" file and not as native package ".deb". Is it even possible?
Just put the process in the background as suggested by #KeepCalmAndCarryOn.
nohup java -jar jenkins.war &
I hope this helps.

Resources