Jenkins had 600+ plugins, in the real system, we are used to install lots of plugins.
And sometimes, we want to remove some plugins to make system more clean or replace with another mature plugin (different name).
This needs to make sure no one/no job use those plugins or I need to notify them.
Are there any ways in configuration or somewhere in Jenkins system to know whether the plugin is used by any jobs ?
UPDATE 2013 Based on the answer below, I maintain the simple "plugin:keyword" mapping, like
plugin_keys = { "git":'scm class="hudson.plugins.git.GitSCM"', "copyartifact":"hudson.plugins.copyartifact.CopyArtifact", # and more }
And search the plugin keyword from the config.xml
, all the information (plugins,jobs,config) can be fetched via jenkins remote API
it works for me.
UPDATE 2014.04.26 Later jenkins version, it seems the config.xml is changed to have plugin name there directly
Like
<com.coravy.hudson.plugins.github.GithubProjectProperty plugin="[email protected]"> <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="[email protected]"> <hudson.plugins.disk__usage.DiskUsageProperty plugin="[email protected]"/> <scm class="hudson.plugins.git.GitSCM" plugin="[email protected]">
Therefore I just check this plugin="<plugin name>"
in config.xml
, it works again
UPDATE 2014.05.05
See complete script in gist jenkins-stats.py
UPDATE 2018.6.7
There is plugin usage plugin support this (no REST API yet)
Pipelines are Jenkins jobs enabled by the Pipeline (formerly called “workflow”) plugin and built with simple text scripts that use a Pipeline DSL (domain-specific language) based on the Groovy programming language.
Navigate to the Jenkins dashboard and select Build History. This timeline displays your build history. This table displays a list of your past builds, time since build and the status of each build.
Here are 2 ways to find that information.
The easiest is probably to to grep the job config files:
E.g. when you know the class name (or package name) of your plugin (e.g. org.jenkinsci.plugins.unity3d.Unity3dBuilder):
find $JENKINS_HOME/jobs/ -name config.xml -maxdepth 2 | xargs grep Unity3dBuilder
Another is to use something like the scriptler plugin, but then you need more information about where the plugin is used in the build.
import hudson.model.* import hudson.maven.* import hudson.tasks.* for(item in Hudson.instance.items) { //println("JOB : "+item.name); for (builder in item.builders){ if (builder instanceof org.jenkinsci.plugins.unity3d.Unity3dBuilder) { println(">>" + item.name.padRight(50, " ") + "\t UNITY3D BUILDER with " + builder.unity3dName); } } } }
Update: here's a small scriplet script that might ease you finding the relevant class names. It can certainly be improved:
import jenkins.model.*; import hudson.ExtensionFinder; List<ExtensionFinder> finders = Jenkins.instance.getExtensionList(ExtensionFinder.class); for (finder in finders) { println(">>> " + finder); if (finder instanceof hudson.ExtensionFinder.GuiceFinder) { println(finder.annotations.size()); for (key in finder.annotations.keySet()) { println(key); } } else if (finder instanceof ruby.RubyExtensionFinder) { println(finder.parsedPlugins.size()); for (plugin in finder.parsedPlugins) { for (extension in plugin.extensions) { println("ruby wrapper for " + extension.instance.clazz); } } } else if (finder instanceof hudson.cli.declarative.CLIRegisterer) { println(finder.discover(Jenkins.instance)); for (extension in finder.discover(Jenkins.instance)) { println("CLI wrapper for " + extension.instance.class); // not sure what to do with those } } else { println("UNKNOWN FINDER TYPE"); } }
(inlined scriplet from my original listJenkinsExtensions submission to http://scriptlerweb.appspot.com which seems down)
Don't forget to backup!
As of early 2018 there is a "Plugins Usage Plugin" that gives you a nice list of the plugins and where they are used. We've noticed that depending on the system sometimes it doesn't seems to catch all the plugins, but it gives a really lovely list of the plugins and all jobs related to a specific plugin in an expandable list.
https://plugins.jenkins.io/plugin-usage-plugin
Plugins used in pipeline scripts would not be listed normally as used by jobs, because they are used dynamically in Jenkinsfiles.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With