From the web UI The simplest and most common way of installing plugins is through the Manage Jenkins > Manage Plugins view, available to administrators of a Jenkins environment. Most plugins can be installed and used immediately by checking the box adjacent to the plugin and clicking Install without restart.
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:
Jenkins.instance.pluginManager.plugins.each{
plugin ->
println ("${plugin.getDisplayName()} (${plugin.getShortName()}): ${plugin.getVersion()}")
}
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:
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)
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
Jenkins 1.588 (2nd of November, 2014) & 1.647 (4th of February, 2016)
Jenkins > Manage Jenkins
System Information
Plugins
The Jenkins CLI supports listing all installed plugins:
java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins
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.
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:
Jenkins.instance.pluginManager.plugins.each{
plugin ->
println ("${plugin.getShortName()}:${plugin.getVersion()}")
}
Jenkins.instance.pluginManager.plugins.each{
plugin ->
println ("${plugin.getShortName()}:latest")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With