how can I know whether the plugin is used by any jobs in jenkins

后端 未结 4 604
天涯浪人
天涯浪人 2021-01-31 07:39

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

4条回答
  •  孤城傲影
    2021-01-31 08:15

    I can't comment because I don't have enough reputation, but if I could, I would point out that the broken link provided by coffeebreaks for the small scriplet script mentioned in the accepted answer can be found on the Internet Archive, at this link:

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

    In case that link breaks, here is the content of the script:

    import jenkins.model.*;
    import hudson.ExtensionFinder;
    
    List 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"); 
      }
    }
    

提交回复
热议问题