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条回答
乱世女痞
2楼-- · 2020-01-27 09:51

From the Jenkins home page:

  1. Click Manage Jenkins.
  2. Click Manage Plugins.
  3. Click on the Installed tab.

Or

  1. Go to the Jenkins URL directly: {Your Jenkins base URL}/pluginManager/installed
查看更多
Animai°情兽
3楼-- · 2020-01-27 09:51

You can be also interested what updates are available for plugins. For that, you have to merge the data about installed plugins with information about updates available here https://updates.jenkins.io/current/update-center.json .

To parse the downloaded file as a JSON you have to read online the second line (which is huge).

查看更多
叼着烟拽天下
4楼-- · 2020-01-27 09:53

If Jenkins run in a the Jenkins Docker container you can use this command line in Bash:

java -jar /var/jenkins_home/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/ list-plugins --username admin --password `/bin/cat /var/jenkins_home/secrets/initialAdminPassword`
查看更多
对你真心纯属浪费
5楼-- · 2020-01-27 09:56

If you are a Jenkins administrator you can use the Jenkins system information page:

http://<jenkinsurl>/systemInfo
查看更多
再贱就再见
6楼-- · 2020-01-27 09:59

If you're working in a docker environment and want to output the plugin list in a plugins.txt format in order to pass that to the install_scripts.sh use these scripts in the http://{jenkins}/script console:

  1. This version is useful for getting specific package version
Jenkins.instance.pluginManager.plugins.each{
  plugin -> 
    println ("${plugin.getShortName()}:${plugin.getVersion()}")
}
  1. If you only want the plugin with the latest version you can use this (thanks @KymikoLoco for the tip)
Jenkins.instance.pluginManager.plugins.each{
  plugin -> 
    println ("${plugin.getShortName()}:latest")
}
查看更多
迷人小祖宗
7楼-- · 2020-01-27 09:59

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<String> jenkinsPlugins = new ArrayList<String>(Jenkins.instance.pluginManager.plugins);
jenkinsPlugins.sort { it.displayName }
              .each { plugin ->
                   println ("${plugin.shortName}:${plugin.version}")
              }

Use the http://<jenkins-url>/script URL to run the code.

查看更多
登录 后发表回答