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

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

    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
    0 讨论(0)
  • 2020-11-30 17:38

    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")
    }
    
    0 讨论(0)
  • 2020-11-30 17:38

    There is a table listing all the plugins installed and whether or not they are enabled at http://jenkins/systemInfo

    0 讨论(0)
  • 2020-11-30 17:41

    The Jenkins CLI supports listing all installed plugins:

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

    0 讨论(0)
  • 2020-11-30 17:42

    Use Jenkins CLI like this:

    java -jar jenkins-cli.jar -s http://[jenkins_server] groovy = < pluginEnumerator.groovy
    

    = in the call means 'read from standard input'. pluginEnumerator.groovy contains the following Groovy code:

    println "Running plugin enumerator"
    println ""
    def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
    plugins.each {println "${it.getShortName()} - ${it.getVersion()}"}
    println ""
    println "Total number of plugins: ${plugins.size()}"
    

    If you would like to play with the code, here's Jenkins Java API documentation.

    0 讨论(0)
  • 2020-11-30 17:42

    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`
    
    0 讨论(0)
提交回复
热议问题