Allan Espinosa

Jenkins Plugin Management in Groovy

2014 October 17

In conjuction with Habit#4 (Tend your Plugin Garden) in [1] . I want to just have the plugins I want on my Jenkins deployment. For my use case, I don’t want to have vanilla deployed plugins like the CVS plugin. Here is a way to disable all plugins at the start.

plugins = Jenkins.instance.pluginManager.plugins
plugins.each {

Plugin Installation

Instead of having your outer config management download the .hpi/ .jpi and wrangle with dependencies yourself, you can take advantage of Jenkin’s builtin Java calls to do exactly the same thing. With this, you can install a plugin from the script console.


Enable a plugin’s dependencies

In the previous section, some of the dependencies will be disabled even though they got updated to the version required by the Git plugin because of the first step we did to disable all plugins. Here, we get all the plugin’s dependencies, and sub dependencies to enable all of them.

git = pm.getPlugin("git")

def deployPlugin(plugin) {
  if (! plugin.isEnabled() ) {
  plugin.getDependencies().each {