How to install Plugins from Jenkins CLI?

HOME

In the previous tutorial, I installed plugins in Jenkins from Jenkins UI. In this tutorial, we will install the plugins from Jenkins CLI.

Step 1 – Verify that the plugin is present in Available option in Plugin Manager

Login to Jenkins UI.

Provide a username and password and click on the Sign-in Button.

Click on the Manage Jenkins. Choose Manage Plugins.

On the Plugin Manager Page, go to the Available option and type Serenity or any plugin of your choice. Here we can see that Serenity is present in the Available option.

Step 2 – Go to Jenkins CLI

Click on the Manage Jenkins. Choose Jenkins CLI.

Step 3 – Download Jenkins CLI

Download jenkins-cli.jar from the Jenkins CLI page as shown in the image.

Step 4 – Run the Jenkins CLI command

Open Windows or PowerShell command line and go to the location where the jenkins-cli.jar file is placed on your machine.

Type the below command.

java -jar jenkins-cli.jar -s http://localhost:8080/ who-am-i

Here, we have not provided the login credentials to login to Jenkins, so the system shows Authenticated as anonymous.

As can be seen in the below image, we need to use -auth to login to Jenkins.

In this case, I have used the below command to login to the Jenkins

java -jar jenkins-cli.jar -s http://localhost:8080/ -auth Username:password who-am-i

To install the plugin, use the below command:

java -jar jenkins-cli.jar -s http://localhost:8080/ -auth username:password install-plugin serenity:1.4

serenity is the name of the plugin and 1.4 is the version of the plugin.

You can see that the Serenity plugin is getting installed.

Now, we need to restart the Jenkins. Use the below command to restart the Jenkins

java -jar jenkins-cli.jar -s http://localhost:8080/ -auth username:password safe-restart

safe-restart plugin allows you to restart Jenkins safely. Jenkins restarts once all running jobs are finished.

To verify that the Serenity plugin is installed or not in Jenkins, please go to Manage Jenkins -> Plugin Manager ->Installed -> Serenity Plugin.

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

Integrate Gradle project with Jenkins
How to generate HTML Reports in Jenkins
How to Schedule a Jenkins Job
Build History Metrics in Jenkins
How to create Jenkins pipeline for Extent Report
How to run parameterized Selenium tests in Jenkins

Leave a comment