How to get a list of installed Jenkins plugins wit

2020-01-27 09:41发布

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 document or example?

21条回答
Explosion°爆炸
2楼-- · 2020-01-27 10:08

Sharing another option found here with credentials

JENKINS_HOST=username:password@myhost.com:port
curl -sSL "http://$JENKINS_HOST/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins" | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g'|sed 's/ /:/'
查看更多
在下西门庆
3楼-- · 2020-01-27 10:11

These days I use the same approach as the answer described by @Behe below instead https://stackoverflow.com/a/35292719/1597808


You can use the API in combination with depth, XPath, and wrapper arguments.

The following will query the API of the pluginManager to list all plugins installed, but only to return their shortName and version attributes. You can of course retrieve additional fields by adding '|' to the end of the XPath parameter and specifying the pattern to identify the node.

wget http://<jenkins>/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins

The wrapper argument is required in this case, because it's returning more than one node as part of the result, both in that it is matching multiple fields with the XPath and multiple plugin nodes.

It's probably useful to use the following URL in a browser to see what information on the plugins is available and then decide what you want to limit using XPath:

http://<jenkins>/pluginManager/api/xml?depth=1
查看更多
孤傲高冷的网名
4楼-- · 2020-01-27 10:11

The Jenkins CLI supports listing all installed plugins:

java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins

查看更多
登录 后发表回答