1
votes

I want to list all available plugins names and their short names using command line option, so that I could automate required plugin installation through jenkins command line.

Kindly advise. Thanks

  • So far I tried to find answer on same however I got answer only for how to list installed plugins, not for all available plugins.
  • I've found this link http://updates.jenkins-ci.org/download/plugins/ which lists all plugins but with their short names only
1

1 Answers

3
votes

You were so close! The LAYOUT is detailed here. The information is nearby for you to parse, hopefully I got it right.

http://updates.jenkins-ci.org/download/plugins/ is indeed the location of the plugins, with the actual plugin versions sitting inside each folder.

https://updates.jenkins.io/ is the root level. You will find the list of all plugins and details at plugin-versions.json.

update-center.js, update-center.json, and update-center.json.html contain actual update center metadata in JSON, JSONP, and HTML format respectively. You can parse the json to pull everything you are looking for. There are also lists for the documentation url and the release history, as well as the updates.

This is where it's nuanced; there's stable (ie:LTS) or latest (ie:weekly) and major releases of each. Each one has its own sublist, depending on minimum version and compatibility.


Plugin Selection Since none of this tells you what the plugins actually do, the best thing is to choose your plugins at https://plugins.jenkins.io/. Clicking on any plugin (eg: mailer) reveals a header block with details:

Mailer 1.23
Minimum Jenkins requirement: 1.642.3
ID: mailer

The ID is the short name you are looking for. Go through and find the plugins you want to use and that's your list. Don't worry about the dependencies.


About Plugin Management

Even on a standalone instance, I use a modified script of Docker install_plugins.sh to generate the full list of plugins to install .

You can examine the outputs or use the groovy script that follows to simplify your "must have" list. Also, as dependency updates happen all the time, I also generate a list of actual installed updates if I need to reapply identically to a different instance rather than from my curated list. My curated list is ~45 plugins, with over 115 getting installed.

eg: workflow-api includes [workflow-scm-step] which includes [git, subversion], so no need to specify git. But you want to know which version you got. Occasionally you may need to explicitly add a dependency to get the latest to avoid a defect, per JENKINS-54018, plugins which were split from Jenkins.

println "Jenkins Instance : " + Jenkins.getInstance().getComputer('').getHostName() + " - " + Jenkins.getInstance().getRootUrl() 
println "Installed Plugins: "
println "=================="
Jenkins.instance.pluginManager.plugins.sort(false) { a, b -> a.getShortName().toLowerCase() <=> b.getShortName().toLowerCase()}.each { plugin ->
   println "${plugin.getShortName()}:${plugin.getVersion()} | ${plugin.getDisplayName()} "
}

println""
println "Plugins Dependency tree (...: dependencies; +++: dependants) :"
println "======================="
Jenkins.instance.pluginManager.plugins.sort(false) { a, b -> a.getShortName().toLowerCase() <=> b.getShortName().toLowerCase()}.each { plugin ->
   println "${plugin.getShortName()}:${plugin.getVersion()} | ${plugin.getDisplayName()} "
   println "+++ ${plugin.getDependants()}"
   println "... ${plugin.getDependencies()}"
   println ''
}

return