218

How can I get a list of installed Jenkins plugins?

I searched the Jenkins Remote Access API document, but it was not found. Should I use Jenkins' CLI? Is there a document or example?

0

23 Answers 23

254

You can retrieve the information using the Jenkins Script Console which is accessible by visiting http://<jenkins-url>/script. (Given that you are logged in and have the required permissions).

Screenshot of the Script Console

Enter the following Groovy script to iterate over the installed plugins and print out the relevant information:

Jenkins.instance.pluginManager.plugins.each{
  plugin -> 
    println ("${plugin.getDisplayName()} (${plugin.getShortName()}): ${plugin.getVersion()}")
}

It will print the results list like this (clipped):

SScreenshot of script output

This solutions is similar to one of the answers above in that it uses Groovy, but here we are using the script console instead. The script console is extremely helpful when using Jenkins.

Update

If you prefer a sorted list, you can call this sort method:

def pluginList = new ArrayList(Jenkins.instance.pluginManager.plugins)
pluginList.sort { it.getShortName() }.each{
  plugin -> 
    println ("${plugin.getDisplayName()} (${plugin.getShortName()}): ${plugin.getVersion()}")
}

Adjust the Closure to your liking (e.g. here it is sorted by the shortName, in the example it is sorted by DisplayName)

8
  • 4
    Of all the answers, this is the most useful for filing a plugin bug report; it can be done using the standard web UI and gives the result in a format that can be easily pasted into the "Environment" field. Commented May 16, 2016 at 12:16
  • 9
    Great answer for quickly creating a plugins.txt for docker Jenkins! Commented Jun 3, 2016 at 6:47
  • 1
    It might be useful to add sorting so that the list of plugins is consistent: Jenkins.instance.pluginManager.plugins.sort({it.getDisplayName()}).each{ plugin -> println ("${plugin.getDisplayName()} (${plugin.getShortName()}): ${plugin.getVersion()}") }
    – wheleph
    Commented Nov 18, 2016 at 13:55
  • 1
    This is the answer we've switched to locally instead of my XPath suggestion above, wrapped with a curl request and some pruning of built from source plugins we use this approach to generate the plugins.txt for our docker image as mentioned by @ErikEnglund above echo 'script=Jenkins.instance.pluginManager.plugins.each{ plugin -> println ("${plugin.getShortName()}:${plugin.getVersion()}") } null' \ | no_proxy=localhost curl --netrc --silent --data-binary @- -X POST "http://localhost:8080/jenkins/scriptText" | sort > plugins.txt
    – dbailey
    Commented Jul 4, 2018 at 14:57
  • 10
    The sort doesn't work, it's an unmodifiableMap these days. Use: jenkins.model.Jenkins.instance.getPluginManager().getPlugins().stream().sorted().each { println "${it.getShortName()} | ${it.getVersion()} | ${it.getDisplayName()}" }
    – Ed Randall
    Commented Dec 19, 2018 at 8:22
108

These days I use the same approach as the answer described by @Behe below instead, updated link: https://stackoverflow.com/a/35292719/3423146 (old link: https://stackoverflow.com/a/35292719/1597808)


You can use the API in combination with depth, XPath, and wrapper arguments.

The following will query the API of the pluginManager to list all plugins installed, but only to return their shortName and version attributes. You can of course retrieve additional fields by adding '|' to the end of the XPath parameter and specifying the pattern to identify the node.

wget http://<jenkins>/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins

The wrapper argument is required in this case, because it's returning more than one node as part of the result, both in that it is matching multiple fields with the XPath and multiple plugin nodes.

It's probably useful to use the following URL in a browser to see what information on the plugins is available and then decide what you want to limit using XPath:

http://<jenkins>/pluginManager/api/xml?depth=1
10
  • 3
    Worked well for me on Mac OS X. I wanted to convert the output to a plain text list, so used some Perl regex to strip the tags: curl 'http://192.168.197.133:8080/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins' | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g'
    – G. Lombard
    Commented Dec 22, 2014 at 1:08
  • 11
    Alternative in JSON format: curl -s -k "http://jenkins/pluginManager/api/json?depth=1" | jq '.plugins[]|{shortName, version,longName}' -c
    – MarkHu
    Commented Jan 8, 2016 at 18:25
  • 1
    Alternative in JSON format without jq: curl -s "http://<jenkins>/pluginManager/api/json?depth=1&tree=plugins\[shortName,version,longName\]"
    – Jean Bob
    Commented Jan 24, 2018 at 11:14
  • 2
    I believe that this requires administration privileges, but I'm not sure.
    – mkobit
    Commented Jan 29, 2018 at 22:16
  • 2
    Confirmed that this requires admin privileges per the 2016-05-11 security advisory.
    – mkobit
    Commented Mar 28, 2018 at 19:02
39

Jenkins 1.588 (2nd of November, 2014) & 1.647 (4th of February, 2016)

  • Jenkins > Manage Jenkins

    enter image description here

  • System Information

    enter image description here

  • Plugins

    enter image description here

1
  • 1
    This is very simple, and I am able to get the list from DEV and PRD server, paste them into Excel and compare their versions side by side.
    – Jirong Hu
    Commented Jul 4, 2016 at 15:53
27

The Jenkins CLI supports listing all installed plugins:

java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins

4
  • This won't list the state of the plugin.
    – akhan
    Commented Mar 3, 2015 at 5:43
  • 2
    And the list-plugins CLI command does not require the user to have the Overall/RunScripts permission as groovy command does. Commented Dec 12, 2017 at 15:14
  • This does not appear to work with an API token if the user/token is not "Overall/Administrator".
    – cgseller
    Commented Mar 25, 2019 at 18:02
  • @JoséAndias: yes, but Overall/Administer seems to be needed, right ?
    – serv-inc
    Commented Jan 9, 2023 at 13:51
27

If you're working in a docker environment and want to output the plugin list in a plugins.txt format in order to pass that to the install_scripts.sh use these scripts in the http://{jenkins}/script console:

  1. This version is useful for getting specific package version
Jenkins.instance.pluginManager.plugins.each{
  plugin -> 
    println ("${plugin.getShortName()}:${plugin.getVersion()}")
}
  1. If you only want the plugin with the latest version you can use this (thanks @KymikoLoco for the tip)
Jenkins.instance.pluginManager.plugins.each{
  plugin -> 
    println ("${plugin.getShortName()}:latest")
}
1
  • 2
    If you want to get the latest versions of all the plugins, you can extend this to only get the short name and add :latest to the end: println ("${plugin.getShortName()}:latest")
    – KymikoLoco
    Commented Oct 23, 2019 at 0:11
25

Use Jenkins CLI like this:

java -jar jenkins-cli.jar -s http://[jenkins_server] groovy = < pluginEnumerator.groovy

= in the call means 'read from standard input'. pluginEnumerator.groovy contains the following Groovy code:

println "Running plugin enumerator"
println ""
def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
plugins.each {println "${it.getShortName()} - ${it.getVersion()}"}
println ""
println "Total number of plugins: ${plugins.size()}"

If you would like to play with the code, here's Jenkins Java API documentation.

4
  • @user1284795, was this helpful? Commented Apr 17, 2012 at 14:19
  • 1
    Hi, do you know how to get the plugins used by Jenkins system and Jenkins job instead of getting all plugins installed? I would like this to help me uninstall all unused plugins. Any help is appreciated. Thanks! Commented May 8, 2014 at 23:30
  • This should be the accepted answer. @user1164061, I don't think there is a any difference between plugins visible to a job vs to the server. There is an isActive() api that you can use in the groovy script in this answer to get the state of the plugin. See javadoc.jenkins-ci.org/hudson/PluginWrapper.html#isActive().
    – akhan
    Commented Mar 3, 2015 at 5:48
  • This answer gets my vote to be the accepted answer.
    – Chris F
    Commented Nov 7, 2020 at 3:48
20

The answers here were somewhat incomplete. And I had to compile information from other sources to actually acquire the plugin list.

1. Get the Jenkins CLI

The Jenkins CLI will allow us to interact with our Jenkins server from the command line. We can get it with a simple curl call.

curl 'localhost:8080/jnlpJars/jenkins-cli.jar' > jenkins-cli.jar

2. Create a Groovy script for parsing (thanks to malenkiy_scot)

Save the following as plugins.groovy.

def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
plugins.each {println "${it.getShortName()}: ${it.getVersion()}"}

3. Call the Jenkins API for plugin results

Call the Jenkins server (localhost:8080 here) with your login username and password while referencing the Groovy script:

java -jar jenkins-cli.jar -s http://localhost:8080 groovy --username "admin" --password "admin" = < plugins.groovy > plugins.txt

The output to plugins.txt looks like this:

ace-editor: 1.1
ant: 1.5
antisamy-markup-formatter: 1.5
authentication-tokens: 1.3
blueocean-autofavorite: 1.0.0
blueocean-commons: 1.1.4
blueocean-config: 1.1.4
blueocean-dashboard: 1.1.4
blueocean-display-url: 2.0
blueocean-events: 1.1.4
blueocean-git-pipeline: 1.1.4
blueocean-github-pipeline: 1.1.4
blueocean-i18n: 1.1.4
blueocean-jwt: 1.1.4
blueocean-personalization: 1.1.4
blueocean-pipeline-api-impl: 1.1.4
blueocean-pipeline-editor: 0.2.0
blueocean-pipeline-scm-api: 1.1.4
blueocean-rest-impl: 1.1.4
2
  • The above commands should run on your workstation and not on a Jenkins job
    – psicopante
    Commented Oct 2, 2018 at 17:01
  • The command seems to result in "ERROR: anonymous is missing the Overall/Read permission" in latest versions.. instead passing the auth before worked for me java -jar jenkins-cli.jar -s localhost:8080 -auth "admin:<password>" groovy = < plugins.groovy
    – prasanna
    Commented Nov 30, 2018 at 7:16
17

With curl and jq:

curl -s <jenkins_url>/pluginManager/api/json?depth=1 \
  | jq -r '.plugins[] | "\(.shortName):\(.version)"' \
  | sort

This command gives output in a format used by special Jenkins plugins.txt file which enables you to pre-install dependencies (e.g. in a docker image):

ace-editor:1.1
ant:1.8
apache-httpcomponents-client-4-api:4.5.5-3.0

Example of a plugins.txt: https://github.com/hoto/jenkinsfile-examples/blob/master/source/jenkins/usr/share/jenkins/plugins.txt

12

Behe's answer with sorting plugins did not work on my Jenkins machine. I received the error java.lang.UnsupportedOperationException due to trying to sort an immutable collection i.e. Jenkins.instance.pluginManager.plugins. Simple fix for the code:

List<String> jenkinsPlugins = new ArrayList<String>(Jenkins.instance.pluginManager.plugins);
jenkinsPlugins.sort { it.displayName }
              .each { plugin ->
                   println ("${plugin.shortName}:${plugin.version}")
              }

Use the http://<jenkins-url>/script URL to run the code.

2
  • 1
    I ran into this as well using a different version of Jenkins than the first system I tested it on. For v2.81 the top answer worked, but for LTS v2.83.x and any newer versions it gave the error you mentioned while your code still worked.
    – dragon788
    Commented Jan 24, 2018 at 21:17
  • 2
    One thing I just noticed is you are sorting based on the displayName while printing out the shortName, this was very confusing as some plugins aren't alphabetically the same for both, and it results in a list that doesn't appear sorted. Changing it.displayName to it.shortName solves this nicely.
    – dragon788
    Commented Oct 19, 2018 at 16:35
10

If you are a Jenkins administrator you can use the Jenkins system information page:

http://<jenkinsurl>/systemInfo
2
  • /systeminfo doesn't work (HTTP 404) on Jenkins 1.594
    – G. Lombard
    Commented Dec 22, 2014 at 0:35
  • 7
    Try http://localhost:8080/systemInfo --some servers are case-sensitive. Note also that it requires the currently logged in user to have Overall/Administer permission.
    – MarkHu
    Commented Jan 8, 2016 at 18:22
4

Sharing another option found here with credentials

JENKINS_HOST=username:[email protected]:port
curl -sSL "http://$JENKINS_HOST/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins" | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g'|sed 's/ /:/'
1
  • as above, but without the versions, and sorted. curl -sSL "http://127.0.0.1:8080/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins" | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \n/g' | sort
    – ffghfgh
    Commented Jun 21, 2017 at 15:57
4

From the Jenkins home page:

  1. Click Manage Jenkins.
  2. Click Manage Plugins.
  3. Click on the Installed tab.

Or

  1. Go to the Jenkins URL directly: {Your Jenkins base URL}/pluginManager/installed
1
  • 2
    The "installed plugins" page doesn't necessarily reflect the real plugin status. E.g. you might re-enable a plugin, and see the plugin checked, while the plugin is still disabled until Jenkins-Restart. Therefore, the only 100% solutions are http://<jenkinsurl>/systeminfo and the API query answers, imho.
    – t0r0X
    Commented Jul 13, 2016 at 13:40
4

I wanted a solution that could run on master without any auth requirements and didn't see it here. I made a quick bash script that will pull out all the versions from the plugins dir.

if [ -f $JENKINS_HOME/plugin_versions.txt ]; then
  rm $JENKINS_HOME/plugin_versions.txt
fi

for dir in $JENKINS_HOME/plugins/*/; do
  dir=${dir%*/}
  dir=${dir##*/}
  version=$(grep Plugin-Version $JENKINS_HOME/plugins/$dir/META-INF/MANIFEST.MF | awk -F': ' '{print $2}')
  echo $dir $version >> $JENKINS_HOME/plugin_versions.txt
done
1
  • grep Plugin-Version */META-INF/MANIFEST.MF | sed -e 's!/META-INF/MANIFEST.MF:Plugin-Version: !:!g' > ../plugins2.txt Commented Apr 2, 2020 at 13:38
3

Another option for Python users:

from jenkinsapi.jenkins import Jenkins

#get the server instance
jenkins_url = 'http://<jenkins-hostname>:<jenkins-port>/jenkins'
server = Jenkins(jenkins_url, username = '<user>', password = '<password>')

#get the installed plugins as list and print the pairs
plugins_dictionary = server.get_plugins().get_plugins_dict()
for key, value in plugins_dictionary.iteritems():
    print "Plugin name: %s, version: %s" %(key, value.version)
2

I think these are not good enough answer(s)... many involve a couple of extra under-the-hood steps. Here's how I did it.

sudo apt-get install jq

...because the JSON output needs to be consumed after you call the API.

#!/bin/bash
server_addr = 'jenkins'
server_port = '8080'

curl -s -k "http://${server_addr}:${server_port}/pluginManager/api/json?depth=1" \
  | jq '.plugins[]|{shortName, version,longName,url}' -c | sort \
  > plugin-list

echo "dude, here's your list: "
cat plugin-list
0
1

There are lots of way to fetch this information but I am writing two ways as below : -

1. Get the jenkins cli.

The jenkins CLI will allow us to interact with our jenkins server from the command line. We can get it with a simple curl call.

curl 'localhost:8080/jnlpJars/jenkins-cli.jar' > jenkins-cli.jar

2. Create a groovy script. OR from jenkins script console

We need to create a groovy script to parse the information we receive from the jenkins API. This will output each plugin with its version. Save the following as plugins.groovy.

def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins() plugins.each {println "${it.getShortName()}: ${it.getVersion()}"}

1

You can be also interested what updates are available for plugins. For that, you have to merge the data about installed plugins with information about updates available here https://updates.jenkins.io/current/update-center.json .

To parse the downloaded file as a JSON you have to read online the second line (which is huge).

1
# list of plugins in sorted order
# Copy this into your Jenkins script console
    def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()

    List<String> list = new ArrayList<String>()

    i = 0
    plugins.each {
      ++i
      //println " ${i}  ${it.getShortName()}: ${it.getVersion()}"
      list.add("${it.getShortName()}: ${it.getVersion()}")
    }

    list.sort{it}
    i = 0
    for (String item : list) {
      i++
      println(" ${i} ${item}")
    }
0

If Jenkins run in a the Jenkins Docker container you can use this command line in Bash:

java -jar /var/jenkins_home/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/ list-plugins --username admin --password `/bin/cat /var/jenkins_home/secrets/initialAdminPassword`
0

For Jenkins version 2.125 the following worked.

NOTE: Replace sections that say USERNAME and APIKEY with a valid UserName and APIKey for that corresponding user. The API key for a user is available via Manage UsersSelect UserAPI Key option.

You may have to extend the sleep if your Jenkins installation takes longer to start.

The initiation yum update -y will upgrade the version as well if you installed Jenkins using yum as well.

#JENKINS AUTO UPDATE SCRIPT link this script into a cron
##############
!/bin/bash
sudo yum update -y
sleep 120
UPDATE_LIST=$( sudo /usr/bin/java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -auth [USERNAME:APIKEY] -s http://localhost:8080/ list-plugins | grep -e ')$' | awk '{ print $1 }' );
if [ ! -z "${UPDATE_LIST}" ]; then
    echo Updating Jenkins Plugins: ${UPDATE_LIST};
    sudo /usr/bin/java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -auth [USERNAME:APIKEY] -s http://localhost:8080/ install-plugin ${UPDATE_LIST};
    sudo /usr/bin/java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -auth [USERNAME:APIKEY] -s http://localhost:8080/ safe-restart;
fi
##############
0

I'm a little surprised this wasn't mentioned here, but the pluginusage URL from the https://plugins.jenkins.io/plugin-usage-plugin/ seems pretty nice and is available to regular users, no admin needed (just to install the plugin). Good to use to check if the Jenkins server you're using has a particular plugin: http://<jenkinsurl>/pluginusage

0

If you have access to Master Server its quite simple. All you have to do is to go to Jenkins directory inside that you will find plugins folder, It contains all the list and data you need. In my case it is at /var/lib/jenkins/plugins

-1

There is a table listing all the plugins installed and whether or not they are enabled at http://jenkins/systemInfo

However, you need administrative rights for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.