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

前端 未结 21 2226
误落风尘
误落风尘 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:45

    Behe's answer with sorting plugins did not work on my Jenkins machine. I received the error java.lang.UnsupportedOperationException due to trying to sort an immutable collection i.e. Jenkins.instance.pluginManager.plugins. Simple fix for the code:

    List jenkinsPlugins = new ArrayList(Jenkins.instance.pluginManager.plugins);
    jenkinsPlugins.sort { it.displayName }
                  .each { plugin ->
                       println ("${plugin.shortName}:${plugin.version}")
                  }
    

    Use the http:///script URL to run the code.

提交回复
热议问题