List Jenkins plugins and dependencies (with graph)
Asked Answered
W

1

11

I have added many plugins to Jenkins. How can I list the plugins and dependencies? Which plugins depend on which ones? Which ones are orphaned or unused, etc.

Ideally, explain how to make a graph (graphviz/dot...) ?

Walloper answered 10/6, 2016 at 21:12 Comment(0)
W
23

Copy-paste this groovy snippet to get a list of plugins (this snippet based on this exemple from zendesk.com):

Note: the groovy must be pasted in _Manage Jenkins >> Script Console

def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
plugins.each {
    println "${it.getShortName()} (${it.getVersion()}) => ${it.getDependencies()}"
}

To produce a graph, execute this snippet to generate a DOT graph (graphviz) file...

def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
println "digraph test {"
plugins.each {
    def plugin = it.getShortName()
    println "\"${plugin}\";"
    def deps =  it.getDependencies()
    deps.each {
      def s = it.shortName
      println "\"${plugin}\" -> \"${s}\";"
    }
} 
println "}"

Then use graphviz to generate an image from the output above:

dot -Tsvg  plugins.txt > plugins.svg
dot -Tpng  plugins.txt > plugins.png

Or copy-paste the output in one of the Graphviz: Online tool capable of accepting larger files

Walloper answered 10/6, 2016 at 21:12 Comment(2)
Is there a way to know the required version of a dependency? As I understand getVersion only list the installed version.Merrilee
Maybe you should add the T before png. It's rather obvious, but so the command is correct ;)Nitz

© 2022 - 2024 — McMap. All rights reserved.