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?
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?
There is a table listing all the plugins installed and whether or not they are enabled at http://jenkins/systemInfo
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.
2. Create a Groovy script for parsing (thanks to malenkiy_scot)
Save the following as
plugins.groovy
.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:The output to plugins.txt looks like this:
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).Enter the following Groovy script to iterate over the installed plugins and print out the relevant information:
It will print the results list like this (clipped):
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:Adjust the Closure to your liking (e.g. here it is sorted by the shortName, in the example it is sorted by DisplayName)
With
curl
andjq
: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):Example of a
plugins.txt
: https://github.com/hoto/jenkinsfile-examples/blob/master/source/jenkins/usr/share/jenkins/plugins.txtFor 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 Users → Select User → API 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.Use Jenkins CLI like this:
=
in the call means 'read from standard input'. pluginEnumerator.groovy contains the following Groovy code:If you would like to play with the code, here's Jenkins Java API documentation.