Last Updated On
In the previous tutorial, I installed plugins in Jenkins from Jenkins UI. In this tutorial, we will install the plugins from Jenkins CLI.
Table of Contents
- Verify that the plugin is present in Available option in Plugin Manager
- Go to Jenkins CLI
- Download Jenkins CLI
- Run the Jenkins CLI command
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.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-73.png?w=1200)
Step 2 – Go to Jenkins CLI
Click on the Manage Jenkins. Choose Jenkins CLI.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-75.png?w=1200)
Step 3 – Download Jenkins CLI
Download jenkins-cli.jar from the Jenkins CLI page as shown in the image.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-76.png?w=1200)
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.
Verify Jenkins CLI identifies the user
Type the below command.
java -jar jenkins-cli.jar -s http://localhost:8080/ who-am-i
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-77.png?w=951)
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.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-78.png?w=1200)
Login to Jenkins from Jenkins CLI
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
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-79.png?w=1167)
Install the plugin from Jenkins CLI
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.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-81.png?w=1153)
You can see that the Serenity plugin is getting installed.
Restart the Jenkins from Jenkins CLI
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.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-82.png?w=1036)
To verify that the Serenity plugin is installed or not in Jenkins, please go to Manage Jenkins -> Plugin Manager ->Installed -> Serenity Plugin.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-83.png?w=1200)
Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!
Additional Tutorials