Many times we need to install more than one instance of Jenkins on the same window machine. Along with installation, we need also setup window service so that Jenkins can itself start after the system reboot.
Let suppose you have already one instance of Jenkins is running, now you need to install another for this you need a Jenkins.war to install Jenkins as well java installed on the system.
Run below command. –DJENKINS_HOME is the path of Jenkin_Home where installation file will be install
java -DJENKINS_HOME=/path/to/configs -jar jenkins --httpPort=<port_num> // java -DJENKINS_HOME=D:Jenkins -jar jenkins.war --httpPort=8081
Now start you Jenkins with URL http://<hostname>:<your_port>. Let assume http://localhost:8081. It will start as a normal installation. Follow all processes of normal installation. After the installation process completed follow the below steps with the assumption that your port is 8081 and Jenkins_Home is “D:Jenkins“
sc.exe create <service_name> binpath= "<path_to_jenkins.exe>" displayname= <service_displayname> start=auto //Example // sc.exe create jenkins_new binpath= "D:jenkinsjenkins.exe" displayname= "jenkins_new" start=auto
Specifies the name given to the Service key in the registry. Note that this is different from the display name (which is what you see with net start command and the Services tool in Control Panel.)
is the label that will identify the service in the service manager interface.
path of jenkins.exe. It is normally exists at JENKINS_HOME path
Run above command cmd (open as administrator). If everything successful 👌 you will see the below message.
If service is stopped then you can start from service manager.
You can also delete created service with the below command
sc delete <service_name> //Example // sc delete jenkins_new
Open Console/Command line –> Go to your Jenkins installation directory. Execute the following commands respectively:
- To stop:
- To start:
- To restart:
To stop Jenkins Please avoid shutting down the Java process or the Windows service. These are not usual commands. Use those only if your Jenkins is causing problems.
Use Jenkins’ way to stop that protects from data loss.
where [command] can be any one of the following:
Example: If my local PC is running Jenkins at port 8080, it will be