1. Overview

Jenkins has a powerful plugin management system that allows the development of extensible plugins. Plugins affect most of Jenkins’ behavior. For example, the Build Timeout plugin terminates a build automatically if it exceeds the allowed time limit, whereas the Mailer plugin configures email notifications about the build results.

In this tutorial, we’ll discuss how to list the installed Jenkins plugins. First, we’ll see how to list the installed plugins using the Jenkins UI (User Interface). Then, we’ll learn how to use the Jenkins CLI (Command-Line Interface) to list the installed plugins from the command line.

The version of Jenkins we use is 2.452.3. Jenkins is running on localhost on port 8080 in our examples. We need to have administration privileges in Jenkins to list the installed plugins.

2. Using the Jenkins Dashboard

One way of listing the installed plugins is to use the Plugins view of the Manage Jenkins page in the Jenkins UI. The Installed plugins tab in this view lists the plugins:

There are many installed plugins, and we need to scroll down to see the other plugins. For example, the version of the Ant Plugin at the top of the list, which adds Apache Ant support to Jenkins, is 497.v94e7d9fffa_b_9.

We can use the http://localhost:8080/manage/pluginManager/installed address to access the page directly in our setup.

3. Using the Jenkins Script Console

Another alternative for listing the installed plugins is the Jenkins Script Console. The Script Console makes it possible to run Groovy scripts within Jenkins.

We can open the Script Console from the Jenkins UI using the Script Console view on the Manage Jenkins page:

Another way of opening the Script Console is by entering http://localhost:8080/manage/script in the browser’s address bar.

Indeed, the example in the Script Console, println(Jenkins.instance.pluginManager.plugins), shows how to get the installed plugins. We can display the details by typing the following Groovy expressions and then pressing the Run button:

The installed plugins are listed in the Result section. As is apparent from the output, the plugin at the top of the list is again the Ant Plugin, whose version is 497.v94e7d9fffa_b_9.

We get the list of installed plugins and assign it to the plugins variable using the def plugins = Jenkins.instance.pluginManager.plugins expression. The jenkins.model package is one of the packages Jenkins pre-imports. So, we don’t need to import it explicitly. The Jenkins class in this package refers to the root object of the Jenkins system. We get the list of installed plugins using Jenkins.instance.pluginManager.plugins.

Then, we iterate the list using plugins.each. The each method in Groovy has the default operator it. Therefore, we can access each element in the plugins list using the it operator. The ${it.getShortName()} expression returns the name of the plugin, whereas the ${it.getVersion()} expression returns the version of the plugin.

Finally, we print the information about each element in the plugin list using the println function, namely println “${it.getShortName()} – ${it.getVersion()}”.

4. Using the Jenkins CLI

We can also list the installed Jenkins plugins using the Jenkins built-in CLI (Command-Line Interface). This CLI allows access to Jenkins from a script or the command line. We access the Jenkins CLI using the CLI client, which is the jenkins-cli.jar file. It can be downloaded from the Jenkins CLI view of the Manage Jenkins page in the Jenkins UI.

The Jenkins CLI supports several commands. We’ll use the list-plugins and groovy commands.

4.1. Using the list-plugins Command

Once we download and move jenkins-cli.jar to the current directory, we can run the client JAR file by invoking the java -jar command:

$ java -jar jenkins-cli.jar -s http://localhost:8080 -auth admin:admin_secret_password list-plugins
ant                                Ant Plugin                                  497.v94e7d9fffa_b_9 (511.v0a_a_1a_334f41b_)
antisamy-markup-formatter          OWASP Markup Formatter Plugin               162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api Apache HttpComponents Client 4.x API Plugin 4.5.14-208.v438351942757
...
workflow-step-api                  Pipeline: Step API                          678.v3ee58b_469476
workflow-support                   Pipeline: Supporting APIs                   920.v59f71ce16f04
ws-cleanup                         Workspace Cleanup Plugin                    0.46

The java -jar command runs the input JAR file, which is jenkins-cli.jar. The remaining options and commands belong to the usage of jenkins-cli.jar.

The -s option specifies the address of the Jenkins controller, which is http://localhost:8080 in our case. The -auth option is for authentication, which expects a username and password as arguments. We pass the username for the Jenkins administrator and its password, namely admin and admin_secret_password in our case. The list-plugins command of the Jenkins CLI lists the installed plugins.

As is apparent from the output, the list consists of three columns. The first two columns contain the short and long names of the plugins, whereas the last column contains the version of each plugin. The plugin at the top of the list is the same Ant Plugin as before.

4.2. Using the groovy Command

Another way of listing the installed plugins using the Jenkins CLI is the groovy command. The groovy command lets us run Groovy scripts. The Groovy script we’ll use is list_installed_plugins.groovy:

$ cat list_installed_plugins.groovy
import jenkins.model.*

def plugins = Jenkins.instance.pluginManager.plugins
plugins.each {println "${it.getShortName()} - ${it.getVersion()}"}

This script contains the same expressions we used while listing the plugins in the Script Console except for the additional expression in the first line, import jenkins.model.*. We need to import the jenkins.model package explicitly in this case.

Let’s now run the list_installed_plugins.groovy script using the groovy command:

$ java -jar jenkins-cli.jar -s http://localhost:8080 -auth admin:admin_secret_password groovy = < list_installed_plugins.groovy
ant - 497.v94e7d9fffa_b_9
antisamy-markup-formatter - 162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api - 4.5.14-208.v438351942757
...
workflow-step-api - 678.v3ee58b_469476
workflow-support - 920.v59f71ce16f04
ws-cleanup - 0.46

The = sign in the groovy = < list_installed_plugins.groovy part of the command causes the Jenkins CLI to listen to stdin. The < sign after = feeds the contents of the list_installed_plugins.groovy script to the Jenkins CLI using stdin.

The listed plugins are the same as before, as expected.

5. Conclusion

In this article, we discussed how to list the installed Jenkins plugins.

First, we saw that we can use the Jenkins Dashboard. Then, we learned that the Jenkins Script Console is another alternative for listing the installed plugins using Groovy.

Finally, we saw how to use the Jenkins CLI, which allows us to use the command line. We used the list-plugins and groovy commands of the CLI.