Restart Jenkins

While working with it, there might be instances when you need to restart Jenkins. For a variety of reasons, such as correcting an error or getting a new Jenkins component, you might need to restart it. However, we have you covered if you are just starting started with Jenkins and do not have a thorough grasp of the methods you must employ to immediately resume Jenkins. You can learn about safe rebooting methods for Jenkins by reading this document's instructions on Jenkins.

Take the following actions to resume Jenkins: Connect to your Jenkins computer or server. Go to the Jenkins Dashboard and, on the left-hand side of the screen, select the "Manage Jenkins" option. Select "Restart Jenkins" from the selection of possible choices on the page. Hold off until Jenkins has finished restarting. Depending on the size of your Jenkins installation and the number of loaded modules, this could take a few seconds to a minute. By using the following instruction, you can alternatively resume Jenkins from the command line: 

 sudo systemctl restart Jenkins

On your server or computer, this command will restore the Jenkins application. Keep in mind that the precise instruction may vary based on your operating system and how Jenkins was deployed.

You can resume Jenkins if you're using it as a Windows application by performing the following actions: Enter "services. msc" into the Start menu search window to launch the Services program. Right-click on the Jenkins server you found in the inventory of services. The "Restart" choice can be found in the context menu. Alternatively, you can resume Jenkins on Windows using the command line by executing the following instruction: 

SQL

Jenkins, net halt & Jenkins, net start

The Jenkins server will be stopped and restarted as a result of this instruction. It's important to keep in mind that restarting Jenkins will stop any active tasks or build processes, which may require explicit restarting. Before restarting Jenkins, it's a good idea to verify the state of any open tasks to prevent losing any work or data.

Ways to Restart Jenkins

Jenkins can be restarted in a variety of methods, as was previously stated. To resume Jenkins on your machine, you can use the URL bar, a secure restart plugin, or the Manage Jenkins option that is accessible on the UI.

1. Restart Jenkins

Jenkins’s resume can be divided into two distinct groups. Restarting securely is the first option, and forcing a reset is the second. Jenkins immediately resumes when you issue a reset command on the URL without finishing the build that is currently being processed. Jenkins can finish the ongoing builds and get them ready for the resume with secure restarting, in contrast. Through Manage Jenkins and the secure resume module, users can reset Jenkins without risk.

2.Employing Jenkins Manage Jenkins can be stopped and started using Manage Jenkins. Under the Manage Jenkins option in the Tools and Action area, there is a choice to "safe shutdown" Jenkins. You can securely terminate Jenkins components thanks to it. Jenkins pauses processing any new builds when this choice is selected and prepares for the shutdown.

To fully comprehend the procedure, adhere to the methods listed below. 

  • Log in to Jenkins first, and then choose "Manage Jenkins" from the options on the left. 
  • Now, select the 'Prepare for Shutdown' option under 'Tools and Shutdown' by scrolling down. 
  • When you select the Prepare for Shutdown option, Jenkins will halt all ongoing builds and wait for those to finish processing. The Jenkins interface will appear after you select the Prepare for Shutdown option. Additionally, you will see a notice similar to the one below.

Restart Jenkins Manually

1. Restart Jenkins via URL

Are you using a desktop browser to view the Jenkins dashboard? If so, you can explicitly restart Jenkins right from the URL. To compel Jenkins to reload, enter the following instruction on the URL. Jenkins will be prevented from completing any currently running builds that restart at the same moment. 

resume at [Jenkins URL] Now, if you want to restart Jenkins securely, which entails permitting Jenkins to carry out all of the action builds, the instruction is a little different. To securely resume Jenkins from the URL, use the command below: /safe restart Jenkins URL You will be taken to the dashboard and a notification box requesting your approval after performing any of the instructions. To finish the reset, press the Yes icon. 

On the Jenkins URL, you can find the hostname and port that Jenkins is operating on your machine. '8080' is the usual number on which Jenkins runs.

Use the following query in the URL field if you are signing into Jenkins from your computer:

 http://localhost:8080/restart

 http://localhost:8080/safeRestart

However, if you are logging in from another system, then use these commands to restart Jenkins manually:

http://[your system's hostname]:8080/restart

http://[your system's hostname]:8080/safe restart

2. Restart Jenkins via Safe Restart Plugin

As we already stated, using the Safe resume Plugin, you can properly resume Jenkins. If the plugin is already loaded, you can resume Jenkins directly from the left menu bar on the interface. You can still add the app if you haven't already by following the instructions below.

  • After logging in to Jenkins, select Manage Jenkins from the left navigation column on the homepage.
  • Next, pick Manage Plugins from the System Configuration menu.
  • After that, select the Available option when the Plugin Manager window appears.
  • Now enter "Safe restart" into the search box. Mark the checkbox next to the component name in the search result.
  • Next, install the component by selecting "Install without restart" from the menu.
  • Return to the interface after loading the extension, then select the Restart Safely option on the left.
  • Lastly, you will receive a notice requesting your approval to resume Jenkins. To reset the device, select Yes.

3. Restart Jenkins via CLI

The Java-based Jenkins command line interface functions as an addition to the user's default terminal environment. Java instructions can be used to control Jenkins from the CLI. With this, users can resume Jenkins directly from the CLI. By taking part in online DevOps certification classes, you will have the opportunity to learn more about Jenkins and its CLI features. However, you must review the procedures below if you want to use Jenkins CLI to resume its operations.

  • Download the Jenkins CLI's.jar file in the first stage.
  • Next, select the Manage Jenkins option in the left-hand navigation column of the Jenkins interface that is visible in your browser.
  • After that, select the Jenkins CLI icon in the Tools and Actions area.
  • Save the Jenkins-cli.jar file.
  • Once the download is finished, launch a terminal window, and enter the code listed below to resume Jenkins.

Java command: java -jar [path to the Jenkins-cli.jar file] -s [Jenkins URL] restart

How to Restart Jenkins in Linux, Windows, and Mac? 

Jenkins launches on your machine and operates in the background. Therefore, using the same straightforward instructions you use to resume other services, you can quickly restart Jenkins on your Linux, Windows, or Mac device. To complete the task, however, we have listed the actions you can take below. Now go check them out!

A) Restart Jenkins in Linux

Run the following syntax on your Linux terminal to restart Jenkins:

sudo systemctl restart Jenkins

B) Restart Jenkins in Windows

Jenkins can be restarted in two different methods on a Windows computer. The actions you must take are listed below.

  • Open the Command Prompt with full privileges on your Windows machine.
  • To resume Jenkins on Windows, enter the following command: net halt Jenkins net start Jenkins.

In addition, there is another method you can use to finish the reset procedure. Here, you must employ a command that enables you to navigate to the download folder and resume the Jenkins'.exe application. Jenkins can be restarted on Windows by using the code listed below.

 Jenkins, program files at C: 

 launch jenkins.exe 

C) Restart Jenkins in MacOS

You must use the fundamental launch commands on your Mac to halt and resume the Jenkins services. heed the instructions here, 

sudo launchctl unload /Library/LaunchDaemons/org.Jenkins-ci. list

Restart Jenkins Stages

No matter if the Pipeline was successful or unsuccessful, you can resume Jenkins steps after it is finished. You can do it from either the Blue Ocean UI or the Jenkins traditional UI. Here's how to go about it:

1. Restarting from the Classic UI

 To resume Jenkins from stages, follow these instructions: 

  • Go to the side section on the traditional UI as your Pipeline finishes.
  • Next, find and select the Restart from Stage option.
  • Following that, you'll be presented with a selection of top-level levels to select from. Choose the level from which to resume. 

A fresh build with a new build number will be assigned as soon as you choose the step to restart. Additionally, the earlier steps will be skipped, and the chosen level will be carried out by the pipeline. After that, the Pipeline will function properly.

  • You should take note that the list will only display the top-level steps that were initially performed in the same execution sequence. It won't show you, too skipped stages because of an earlier failure.
  • You will discover the missed steps, though, because a requirement wasn't met. The progenitor stage for a collection of parallel stages is also included in the inventory of unavailable stages. Additionally, the group nested phases that were meant to execute one after the other won't be accessible

2. Restarting from the Blue Ocean UI

Although phases can be restarted from the traditional UI, the Blue Ocean Plugin provides a simple and user-friendly interface. Users can easily observe pipeline steps thanks to this. To resume Jenkins stages through Blue Ocean UI, follow these steps:

  • To locate your project's Pipeline, first go to the CI service website for your project and choose the Open Blue Ocean choice from the left menu.
  • To resume a build, click on the Pipeline and then the desired build.
  • The level from which you want to resume must then be chosen.
  • Finally, a fresh Jenkins run based on the stage you chose and the same commit details as the previous run will be launched.

A new summary that indicates the build's prior iteration will also be produced, much like the previous procedure.

Conclusion

We trust you won't run into problems when attempting to restart Jenkins directly or in any other manner now that you are aware of how to do it. Jenkins can now be restarted more easily on Linux, Windows, and Mac. However, KnowledgeHut's online Jenkins training can only be helpful to you if you need more details on Jenkins and how it functions. This online training will greatly improve your understanding of Jenkins, the restart instruction for Jenkins, and how it functions.