Skip to content

Instantly share code, notes, and snippets.

@noqcks
Last active January 2, 2024 15:46
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save noqcks/d2f2156c7ef8955619d45d1fe6daeaa9 to your computer and use it in GitHub Desktop.
Save noqcks/d2f2156c7ef8955619d45d1fe6daeaa9 to your computer and use it in GitHub Desktop.
How to get a complete plugin list from jenkins (with version)

I need a way to get a list of plugins so that I can use them with docker jenkins in the format <plugin>: <version>

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.

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()}"}

3. call the Jenkins API.

Use jenkins-cli.jar to call the jenkins server where it is located (localhost:8080) in this case with the username and password you use for login and then output the results to plugins.txt

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

The output 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

Enjoy!

@deadc
Copy link

deadc commented Oct 23, 2018

Just a update, the API authentication is now a little different:

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

Thanks!

@imolavirus
Copy link

This saved a lot of time, thanks!

@hashim-notified
Copy link

Is there any option to get update version of the plugins, If you click "manage plugins" you can see an option "updates" so I need to get current version and update version of each plugins.

@saquibtmf
Copy link

This does not list all the plugins.

@rajeshw61
Copy link

rajeshw61 commented Jul 2, 2022

http://jenkins-url/systemInfo should list all plugins info with versions

@nchandra-seg
Copy link

Is there API to delete plugins?
If there is API to delete all unused plugins, even better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment