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.
Related
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.
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.
I have installed latest jenkins.war from
https://updates.jenkins-ci.org/download/war/
after that I have triggered that WAR file as
java -jar jenkins.war in command prompt.
I have attached the screen shots of the same.
As I could understand from the logs that, port which jenkins trying to operate on is already in use.
would appreciate the any help on this!
By default, Jenkins will bind on port 8080 (listening address will be http://localhost:8080), you can change this port by editing the jenkins.xml file that is located in the directory where you installed Jenkins.
Change it for another value and relaunch. (or try to find who is already listening on this 8080 port, probably a web server)
By the way, instead of downloading the jenkins.war, it would be better to use the native windows installer, that will install/start jenkins as a service.
You can change the port without editing jenkins.xml. This can be useful when you are doing an initial setup where you don't have a jenkins.xml yet.
java -jar jenkins.war --httpPort=<your port>
You can also run Jenkins this way with an existing jenkins.xml. In my case I can access the Jenkins UI using both ports. When one of both ports is already used by the system like in your case, Jenkins won't start.
I'm trying to run UI automation with a Jenkins job that runs on a windows VM as a jenkins slave, as a part of a CI pipeline.
I have a problem that the screen resolution is set to be very low (1024, 768)
how can I change the default resolution, so that when jenkins opens a new connection it will be with a larger resolution?
If your UI automation involves running Chrome, you might find it helpful to run Headless Chrome. That way, the screen resolution of the slave won't matter as you can specify the resolution you want to be used.
I was able to achieve this with these Chrome startup arguments running on a Windows Server Jenkins slave:
--headless --window-size=1920,1080
In my case, with Nightwatch, this is a snippet of the nightwatch.json file:
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": ["--window-size=1920,1080", "--headless"]
},
// ...
Do you have your webapp container started as a local service (tomcat or jenkins slave?). The point is that windows services cannot have GUI and it's even a miracle, that WebDriver somehow manages to open a 1024,768 window :)
Start your webapp container as a console application with a normal user.
I've got the same issue while trying to run UI tests on Jenkins
Problem: By default jenkins ran as windows service and have not access to run tests on desktop.
So fix:
run >> services.msc >> stop the system service Jenkins.exe
right click on Jenkins.exe >> properties >> startup type - Manual >> save
create an executable file (.bat, .exe, ...) save it somewhere and type there:
java -jar "C:\path\to\Jenkins\jenkins.war" --httpPort=8081
add shortcut of this executable file to windows autorun directory
It will run Jenkins on Desktop (non windows service) what allows run your UI tests there
Theoretically, running powerscript command as the build step:
set-displayresolution 1920 1080 -Force
should do it, but I have some problems with right now...
What has definitely worked: connect to your VM with RDP using desired resolution, then disconnect. The tests will run in the last resolution used.
I am facing the same issue. And found two different resolutions.
If your requirement is to see the chrome browser then open the command prompt and execute the below command
Java -jar jenkins.war
If your goal is just to change the resolution then add the below options and you can see the configure resolution(in the below example resolution is 1920,1080):-
ChromeOptions options = new ChromeOptions();
options.addArguments("enable-automation");
options.addArguments("--headless");
options.addArguments("--window-size=1920,1080");
options.addArguments("--no-sandbox");
options.addArguments("--disable-extensions");
options.addArguments("--dns-prefetch-disable");
options.addArguments("--disable-gpu");
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