Bird
Raised Fist0
Jenkinsdevops~5 mins

Jenkins WAR file execution - Commands & Configuration

Choose your learning style10 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.

Practice

(1/5)
1. What does running java -jar jenkins.war do in Jenkins?
easy
A. Deletes Jenkins configuration files
B. Installs Jenkins permanently on the system
C. Updates Jenkins to the latest version
D. Starts Jenkins server without installing it

Solution

  1. Step 1: Understand the command purpose

    The command java -jar jenkins.war runs the Jenkins server directly from the WAR file without installation.
  2. Step 2: Differentiate from installation

    This method does not install Jenkins permanently but starts it temporarily for use or testing.
  3. Final Answer:

    Starts Jenkins server without installing it -> Option D
  4. Quick Check:

    Run WAR file = Start Jenkins temporarily [OK]
Hint: WAR file runs Jenkins without install, just start it [OK]
Common Mistakes:
  • Thinking it installs Jenkins permanently
  • Confusing it with Jenkins update command
  • Assuming it deletes files
2. Which command correctly starts Jenkins on port 9090 using the WAR file?
easy
A. java -jar jenkins.war --httpPort=9090
B. java -jar jenkins.war -p 9090
C. java -jar jenkins.war --port 9090
D. java -jar jenkins.war -httpPort 9090

Solution

  1. Step 1: Recall Jenkins WAR port option syntax

    The correct option to specify port is --httpPort=9090 when running the WAR file.
  2. Step 2: Check other options for correctness

    Options B, C, and D use incorrect flags or syntax not recognized by Jenkins WAR execution.
  3. Final Answer:

    java -jar jenkins.war --httpPort=9090 -> Option A
  4. Quick Check:

    Use --httpPort=number to set port [OK]
Hint: Use --httpPort=PORT to set Jenkins port [OK]
Common Mistakes:
  • Using -p or --port which Jenkins WAR does not recognize
  • Missing equal sign in option
  • Using single dash for long option
3. What will be the output if you run java -jar jenkins.war --httpPort=8080 when port 8080 is already in use?
medium
A. Error: Address already in use, Jenkins fails to start
B. Jenkins automatically switches to port 8081
C. Jenkins starts successfully on port 8080
D. Jenkins ignores the port option and uses default

Solution

  1. Step 1: Understand port conflict behavior

    If the specified port (8080) is busy, Jenkins cannot bind to it and will fail to start with an error.
  2. Step 2: Check Jenkins automatic port fallback

    Jenkins WAR does not automatically switch ports; it requires manual change if port is busy.
  3. Final Answer:

    Error: Address already in use, Jenkins fails to start -> Option A
  4. Quick Check:

    Port busy = Jenkins start error [OK]
Hint: Busy port causes Jenkins start error, no auto-switch [OK]
Common Mistakes:
  • Assuming Jenkins auto-switches ports
  • Thinking Jenkins ignores port option
  • Believing Jenkins starts anyway on busy port
4. You ran java -jar jenkins.war --httpPort=abc and Jenkins did not start. What is the likely cause?
medium
A. Jenkins requires root privileges to start
B. Jenkins WAR file is corrupted
C. Invalid port number format causes startup failure
D. Java is not installed on the system

Solution

  1. Step 1: Analyze the port option value

    The port option --httpPort=abc uses non-numeric characters, which is invalid for a port number.
  2. Step 2: Understand Jenkins port validation

    Jenkins expects a numeric port; invalid format causes startup failure with error.
  3. Final Answer:

    Invalid port number format causes startup failure -> Option C
  4. Quick Check:

    Port must be numeric for Jenkins to start [OK]
Hint: Port must be a number, not letters [OK]
Common Mistakes:
  • Blaming Jenkins WAR file corruption
  • Assuming Java is missing without checking
  • Thinking root privileges are always needed
5. You want to run Jenkins WAR file on port 7070 and also specify a custom Jenkins home directory at /data/jenkins_home. Which command is correct?
hard
A. java -jar jenkins.war --httpPort=7070 --jenkinsHome=/data/jenkins_home
B. java -Djenkins.home=/data/jenkins_home -jar jenkins.war --httpPort=7070
C. java -jar jenkins.war --httpPort=7070 --jenkins.home=/data/jenkins_home
D. java -jar jenkins.war --httpPort=7070 -DjenkinsHome=/data/jenkins_home

Solution

  1. Step 1: Set port option correctly

    The port is set with --httpPort=7070, which is correct syntax.
  2. Step 2: Set Jenkins home directory properly

    Jenkins home is set via Java system property -Djenkins.home=path, not as a command option.
  3. Step 3: Verify option correctness

    The correct command places the -Djenkins.home= option before -jar to set the system property properly.
  4. Final Answer:

    java -Djenkins.home=/data/jenkins_home -jar jenkins.war --httpPort=7070 -> Option B
  5. Quick Check:

    Use -Djenkins.home=PATH for custom Jenkins home [OK]
Hint: Use -Djenkins.home=PATH to set Jenkins home [OK]
Common Mistakes:
  • Using --jenkinsHome or --jenkins.home as options
  • Confusing Java system properties with command options
  • Missing -D prefix for system properties
  • Placing -D option after -jar which is incorrect
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard