How to get a list of installed Jenkins plugins with name and version pair

前端 未结 21 2209
误落风尘
误落风尘 2020-11-30 17:14

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 d

21条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 17:28

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

提交回复
热议问题