Jenkins server starts from cmd.exe with help of python subprocess
- StartJenkinsServer (from cmd.exe and REST API verification)
- SubprocessUtility (common user)
This guide explains how to download and install Jenkins, configure Java (JDK 21), and set up the environment variables for Java.
- Visit the official Oracle JDK 21 download page:
- Choose either
.exe
or.msi
depending on your preference (for most users,.exe
is recommended).
- Run the downloaded installer and follow the instructions to install Java.
- By default, it will be installed in
C:\Program Files\Java\jdk-21
.
- Right-click on This PC or My Computer and select Properties.
- Click Advanced system settings → Environment Variables.
- Under System Variables, click New.
- Variable name:
JAVA_HOME
- Variable value:
C:\Program Files\Java\jdk-21
- Variable name:
- Click OK.
-
In the same Environment Variables window, under System Variables, scroll down and find
Path
. -
Select
Path
and click Edit. -
Click New and add the following:
%JAVA_HOME%\bin
-
Click OK to save changes.
- Open a new Command Prompt window and run the following commands:
java -version
java version "21.0.4" 2024-07-16 LTS
Java(TM) SE Runtime Environment (build 21.0.4+8-LTS-274)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.4+8-LTS-274, mixed mode)
- Also verify the
JAVA_HOME
value:echo %JAVA_HOME%
This should return:C:\Program Files\Java\jdk-21
- Go to the official Jenkins website and download the latest LTS version:
- Choose the Windows installer (
.msi
).
- Run the downloaded
.msi
file and follow the installation steps. - During installation, Jenkins will check for a compatible Java version. If you've set up
JAVA_HOME
correctly, it should detect Java 21.
- After installation, open Jenkins in your browser using:
http://localhost:8080
- Use the initialAdminPassword located at:
C:\ProgramData\Jenkins\.jenkins\secrets\initialAdminPassword
If you cannot see the secrets directory or the initialAdminPassword
file, follow these steps:
-
Restart Jenkins:
- Open the Run dialog (Windows + R), type
services.msc
, and press Enter. - Find Jenkins in the list, right-click on it, and select Restart.
- Open the Run dialog (Windows + R), type
-
Check the Secrets Directory:
- Open Command Prompt and run:
dir "C:\ProgramData\Jenkins\.jenkins\secrets"
- Open Command Prompt and run:
-
Check Jenkins Log Files:
-
If the secrets directory is still missing, you can check the log files for any errors:
type "C:\Program Files\Jenkins\jenkins.err.log" type "C:\Program Files\Jenkins\jenkins.out.log"
-
Follow the on-screen instructions to complete the Jenkins setup and create the admin user.
Jenkins initial setup is required. An admin user has been created and a password generated. Please use the following password to proceed to installation: 754240566b9e4748b1698f4f87ae9615 This may also be found at: C:\ProgramData\Jenkins\.jenkins\secrets\initialAdminPassword
-
- Ensure that Jenkins is running correctly by visiting:
http://localhost:8080
- You can start/stop Jenkins via the Services management console in Windows.
C:\ProgramData\Jenkins\.jenkins\workspace
-
Make sure JENKINS_HOME is set to the directory where your existing Jenkins data is stored, such as "C:\Users\ADMIN.jenkins". This will help Jenkins load your previous configurations.
set JENKINS_HOME="C:\Users\ADMIN\.jenkins"
-
Or, if you want it permanently, you can set it through System Properties:
Go to Control Panel > System > Advanced system settings > Environment Variables. Under System variables,
click New and add JENKINS_HOME with the value "C:\Users\ADMIN\.jenkins".
- You can start Jenkins using the .exe with this command to ensure it uses the JENKINS_HOME you set:
"C:\Program Files\Jenkins\jenkins.exe" --httpPort=8080
-
If the .exe option doesn’t load the existing configurations, try starting with jenkins.war while specifying JENKINS_HOME:
java -Djenkins.home="C:\Users\ADMIN\.jenkins" -jar "C:\Program Files\Jenkins\jenkins.war" --httpPort=8080