How to Restart Jenkins Manually {4 Methods} – phoenixNAP

Introduction

While working in Jenkins, users may find themselves in a situation where they need to restart it manually. This can occur due to different reasons such as troubleshooting or installing plugins. Fortunately, Jenkins offers several methods to perform a manual reboot.

In this tutorial, we will go over the different methods used to restart Jenkins manually.

Prerequisites

  • A copy of Jenkins installed and ready to use (learn how to install Jenkins on Ubuntu 18.04, Debian 10, CentOS 8 or Windows 10
  • ). Access to a web browser. Access to

  • the terminal window (Linux and macOS) or command prompt (Windows).
  • Access to a user account with sudo/administrator privileges.

Restart Jenkins via

URL If you are using the Jenkins dashboard in a web browser, restart Jenkins by entering the appropriate URL. Using the default restart URL forces Jenkins to restart without waiting for any build to complete: [Jenkins URL

]/restart

To complete all jobs that are currently running before the restart, use the secure restart option. New jobs will be queued and run after

the restart is complete: [Jenkins URL]/safeRestart

Both options require confirming the restart by clicking the Yes:

The Jenkins URL

contains the host name of the system and the port on which Jenkins is running (the default port is 8080). If you

are logging into the Jenkins dashboard on your system, use: http://localhost:8080/restart http://localhost:8080/safeRestart

If you are logging in to another system, use

: http://[your system hostname]:8080/restart http://[your system hostname]:8080/safeRestart Restarting Jenkins via the Secure Restart Plugin The Secure Restart plugin for Jenkins

allows you to perform a secure restart from the Jenkins dashboard.

1. To add the plugin, start by clicking the Manage Jenkins link on the left side of the dashboard:

2. In the System Settings section, click the Manage Add-ons: 3 button

. On the Available tab, look for “Safe Restart” and check the box next to the name of the Safe Restart snap-in.

4. Click the Install without restarting button to add the plugin:

5. Once the plugin is installed, return to your dashboard. There is now a Safely Restart link on the left side:

6. Clicking the link initiates a secure restart of Jenkins. You need to confirm the restart by clicking the Yes:

Restart Jenkins via CLI

Jenkins CLI

(Command Line Interface) is a Java file that functions as a shell extension of the local terminal. Allows you to use Java commands to manage Jenkins from a terminal window or command prompt.

1. Start by downloading the Jenkins CLI .jar file.

2. Open the Jenkins dashboard in

your web browser and click the Manage Jenkins link on the left side

.

3. Scroll down and click the Jenkins CLI button in the Tools and Actions section.

4. Download jenkins-cli.jar using the link provided.

5. After the download is complete, open the terminal window or command prompt and use the following command syntax

to restart Jenkins: java -jar [path to jenkins-cli file.jar] -s [Jenkins URL] restart For example, using the jenkins-cli file.jar in the Downloads folder on a Windows system: java -jar C:UsersakovaDownloads

jenkins-cli.jar –

s http://localhost:8080/ restart

How to restart Jenkins on Linux, Windows and Mac

Once installed, Jenkins runs as a background service. This means that you can restart it with the same commands used to restart any other service.

Restart the Jenkins service on Linux

On a Linux system, start a restart of

the Jenkins service with: sudo systemctl restart jenkins

Another method is to use

: sudo /etc/init.d/jenkins restart Restart the Jenkins service in Windows

Restart

the

Jenkins service at the Windows command prompt by using the net command to stop and start the service:

net stop jenkins net start jenkins

Another method is to move to the Jenkins installation folder and restart jenkins.exe. For example

: cd C:Program FilesJenkins jenkins.exe restart Restart the Jenkins service on MacOS

To restart the Jenkins service on MacOS, stop the service and start it again using the launchctl command

: sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

Conclusion

After reading this tutorial, you should be able to use one of the methods described above to restart Jenkins manually.

Contact US