In the previous tutorial, I have 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 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 Jenkins CLI page as shown in the image.

Step 4 – Run 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 credential to login to the Jenkins, so the system shows Authenticated as anonymous.
As it can be seen in the below image that we need to use -auth to login to the Jenkins.

In this case, I have used below command to login to the Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080/ -auth Username:password who-am-i

To install 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!!