How can I find out if the plugin is used for any jobs in jenkins

Jenkins had 600+ plugins, in the real system we are used to installing many plugins.

And sometimes we want to remove some plugins to make the system cleaner, or replace them with another mature plugin (another name).

This should ensure that no one / no work uses these plugins, or I must notify them.

Are there any ways in the configuration or somewhere on the Jenkins system to find out if the plugin is used for any tasks?

UPDATE 2013 Based on the answer below, I support a simple "plugin: keyword" display, for example

plugin_keys = { "git":'scm class="hudson.plugins.git.GitSCM"', "copyartifact":"hudson.plugins.copyartifact.CopyArtifact", # and more } 

And find the plugin keyword from config.xml , all information (plugins, tasks, config) can be obtained through the remote jenkins API.

it works for me.

UPDATE 2014.04.26 A later version of jenkins, it seems that config.xml has been changed to have the plugin name there

like

 <com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.4"> <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@1.7.2"> <hudson.plugins.disk__usage.DiskUsageProperty plugin="disk-usage@0.18"/> <scm class="hudson.plugins.git.GitSCM" plugin="git@1.4.1-SNAPSHOT"> 

So I just check this plugin="<plugin name>" in config.xml , it works again

UPDATE 2014.05.05

See the full script at Gist jenkins-stats.py

UPDATE 2018.6.7

There is support for plugins using plugins (there is no REST API yet)

+33
jenkins jenkins-plugins
Aug 09 '13 at 0:20
source share
3 answers

Here are two ways to find this information.

The easiest way is to have grep job configuration files:

eg. 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 a scriptler plugin , but then you need more information about where the plugin is used in the assembly.

 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 is a small script script that can make it easier for you to find the appropriate class names. This 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"); } } 

(the inline script from my original listJenkinsExtensions list for http://scriptlerweb.appspot.com that seems empty)

Do not forget to backup!

+15
Aug 10 '13 at 5:44
source share

I can’t comment because I don’t have enough reputation, but if I could, I would indicate that the broken coffeebreaks link for the small script script mentioned in the accepted answer can be found in the online archive at this link:

https://web.archive.org/web/20131103111754/http://scriptlerweb.appspot.com/script/show/97001

In case of link breaking, here is the content of the script:

 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"); } } 
+6
Nov 17 '15 at 16:10
source share

As of the beginning of 2018, the “Plugin for using plugins” has appeared, which gives you a good list of plugins and places to use them. We noticed that depending on the system it sometimes seems that it does not intercept all plugins, but gives a really excellent list of plugins and all the tasks associated with a particular plugin in an expandable list.

https://plugins.jenkins.io/plugin-usage-plugin

+4
Jun 04 '18 at 20:56
source share



All Articles