0
0
Jenkinsdevops~5 mins

Jenkins WAR file execution - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes you want to run Jenkins quickly without installing it fully. The Jenkins WAR file lets you start Jenkins as a simple Java program. This helps you test or run Jenkins on any machine with Java installed.
When you want to try Jenkins without installing it on your system.
When you need a quick Jenkins server for testing or demos.
When you want to run Jenkins on a machine without root access.
When you want to run Jenkins in a container or script easily.
When you want to upgrade Jenkins by replacing the WAR file.
Commands
This command starts Jenkins using the WAR file. It runs Jenkins on the default port 8080 so you can open it in your browser.
Terminal
java -jar jenkins.war
Expected OutputExpected
Running from: /home/user/jenkins.war webroot: /home/user/.jenkins 2024-06-01 12:00:00.000+0000 [id=1] INFO org.eclipse.jetty.server.Server#start: Started @12345ms 2024-06-01 12:00:00.000+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins is fully up and running
This command checks if Jenkins is running by requesting the login page. It shows the HTML content if Jenkins is up.
Terminal
curl http://localhost:8080/login
Expected OutputExpected
<!DOCTYPE html> <html lang="en"> <head><title>Jenkins</title></head> <body> <h1>Login</h1> <form>...</form> </body> </html>
This command starts Jenkins on port 9090 instead of the default 8080. Use this if 8080 is busy or you want a different port.
Terminal
java -jar jenkins.war --httpPort=9090
Expected OutputExpected
Running from: /home/user/jenkins.war webroot: /home/user/.jenkins 2024-06-01 12:05:00.000+0000 [id=1] INFO org.eclipse.jetty.server.Server#start: Started @12345ms 2024-06-01 12:05:00.000+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins is fully up and running
--httpPort=9090 - Sets Jenkins to listen on port 9090
Key Concept

If you remember nothing else from this pattern, remember: running Jenkins with the WAR file lets you start Jenkins quickly without installation by using a simple Java command.

Common Mistakes
Trying to run 'jenkins.war' without 'java -jar' prefix
The WAR file is not an executable by itself; it needs the Java runtime to run it.
Always run Jenkins WAR with 'java -jar jenkins.war' command.
Not waiting long enough for Jenkins to start before accessing the web page
Jenkins takes a few seconds to start; accessing too early causes connection errors.
Wait a few seconds after starting Jenkins before opening the browser or using curl.
Trying to run Jenkins on a port already in use without changing the port
Jenkins will fail to start if the port is busy, causing errors.
Use the --httpPort flag to specify a free port like 9090.
Summary
Run Jenkins quickly without installation using 'java -jar jenkins.war'.
Check Jenkins is running by accessing http://localhost:8080 or using curl.
Change the port with '--httpPort=PORT' if needed to avoid conflicts.