如何获取具有名称和版本对的已安装Jenkins插件的列表 [英] How to get a list of installed Jenkins plugins with name and version pair

查看:595
本文介绍了如何获取具有名称和版本对的已安装Jenkins插件的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取已安装的Jenkins插件的列表?

How can I get a list of installed Jenkins plugins?

我搜索了Jenkins远程访问API文档,但没有找到.我应该使用Jenkins的CLI吗?有文件或示例吗?

I searched the Jenkins Remote Access API document, but it was not found. Should I use Jenkins' CLI? Is there a document or example?

推荐答案

您可以使用

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).

输入以下 Groovy脚本以遍历已安装的插件并打印出相关信息:

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):

此解决方案类似于上面的答案之一,因为它使用了Groovy,但是这里我们使用的是脚本控制台代替.使用Jenkins时,脚本控制台非常有用.

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.

更新

如果您希望使用排序列表,则可以将其称为

If you prefer a sorted list, you can call this sort method:

Jenkins.instance.pluginManager.plugins.sort { it.getDisplayName() }.each{
  plugin -> 
    println ("${plugin.getDisplayName()} (${plugin.getShortName()}): ${plugin.getVersion()}")
}

根据自己的喜好调整关闭时间.

Adjust the Closure to your likings.

这篇关于如何获取具有名称和版本对的已安装Jenkins插件的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆