Last active
March 1, 2017 12:13
-
-
Save waltervargas/32132ceddbf69eab187aec20b4835703 to your computer and use it in GitHub Desktop.
Jenkins Plugins Installation from Groovy Init
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!groovy | |
import jenkins.model.* | |
import java.util.logging.Logger | |
def log = Logger.getLogger("") | |
def instance = Jenkins.getInstance() | |
def updateCenter = instance.getUpdateCenter() | |
def pluginManager = instance.getPluginManager() | |
def plugins = "git pipeline-stage-view job-dsl github workflow-aggregator".split() | |
def plugins_installed = false | |
log.info("" + plugins) | |
updateCenter.updateAllSites() | |
plugins.each { | |
log.info("plugin: " + it) | |
if (!pluginManager.getPlugin(it)) { | |
def plugin = updateCenter.getPlugin(it) | |
if (plugin){ | |
plugin.deploy() | |
plugins_installed = true | |
log.info("Installing plugin " + it) | |
} | |
} | |
} | |
if (plugins_installed){ | |
instance.save() | |
instance.doSafeRestart() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This file should be under the path
/var/lib/jenkins/init.groovy.d