$JENKINS_HOME/init.groovy.d/
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e59e3c84-27e5-4c47-a4f9-20e76860ef2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/**
* activatePlugin activates given plugins.
* The plugin parameter is a pluginManager object(?)
*
* @param plugin [Object]
*
* @return nil
*/
def activatePlugin(plugin) {
// If our specified plugin isn't enabled, enable it.
if (! plugin.isEnabled()) {
plugin.enable()
// Set our state to true.
deployed = true
}
// Go through each dependency of our plugins, and enable those.
// Otherwise our plugins wouldn't work even if they're installed.
plugin.getDependencies().each {
activatePlugin(pluginManager.getPlugin(it.shortName))
}
}
// As of 2018-12-18
def plugin_list = [
"ant:1.9",
"build-timeout:1.19",
"email-ext:2.63",
"github-branch-source:2.4.1",
"gradle:1.29",
"ldap:1.20",
"matrix-auth:2.3",
"antisamy-markup-formatter:1.5",
"pam-auth:1.4",
"pipeline:2.6",
"pipeline-github-lib:1.0",
"ssh-slaves:1.29.1",
"subversion:2.12.1",
"timestamper:1.8.10",
"ws-cleanup:0.37",
]
// Loop through all of the plugins and install/update and activate them.
plugin_list.each { plugin ->
// If the plugin isn't being installed, update it.
if (! pluginManager.getPlugin(plugin)) {
deployment = updateCenter.getPlugin(plugin).deploy(true)
deployment.get()
}
// Activate the plugin and all of its dependencies.
activatePlugin(pluginManager.getPlugin(plugin))
}
import jenkins.model.Jenkins;
pm = Jenkins.instance.pluginManager
uc = Jenkins.instance.updateCenter
pm.plugins.each { plugin ->
plugin.disable()
}
deployed = false
def activatePlugin(plugin) {
if (! plugin.isEnabled()) {
plugin.enable()
deployed = true
}
plugin.getDependencies().each {
activatePlugin(pm.getPlugin(it.shortName))
}
}
["git", "workflow-aggregator", "github-oauth", "job-dsl", "extended-read-permission"].each {
if (! pm.getPlugin(it)) {
deployment = uc.getPlugin(it).deploy(true)
deployment.get()
}
activatePlugin(pm.getPlugin(it))
}
if (deployed) {
Jenkins.instance.restart()
}
import jenkins.model.Jenkins;
pm = Jenkins.instance.pluginManager
uc = Jenkins.instance.updateCenter
pm.plugins.each { plugin ->
plugin.disable()
}
deployed = false
/**
*
*/
def activatePlugin(plugin) {
if (! plugin.isEnabled()) {
plugin.enable()
deployed = true
}
plugin.getDependencies().each {
activatePlugin(pm.getPlugin(it.shortName))
}
}
/** this works.
[
"git",
"workflow-aggregator",
"github-oauth",
"job-dsl",
"extended-read-permission"
].each {
if (! pm.getPlugin(it)) {
deployment = uc.getPlugin(it).deploy(true)
deployment.get()
}
activatePlugin(pm.getPlugin(it))
}
*/
[
"ant",
"build-timeout",
"credentials",
"email-ext",
"github-branch-source:",
"gradle",
"jobConfigHistory",
"ldap",
"matrix-auth",
"antisamy-markup-formatter",
"pam-auth",
"pipeline",
"pipeline-github-lib",
"ssh-slaves",
"subversion",
"timestamper",
"ws-cleanup"
].each {
if (! pm.getPlugin(it)) {
deployment = uc.getPlugin(it).deploy(true)
deployment.get()
}
activatePlugin(pm.getPlugin(it))
}
#!groovy
import jenkins.model.Jenkins
import hudson.util.VersionNumber
// Create a reference to the PluginManager Class.
pm = Jenkins.instance.pluginManager
// Create a reference to the UpdateCenter Class.
uc = Jenkins.instance.updateCenter
// Disable all the plugins on the system first.
pm.plugins.each { plugin ->
plugin.disable()
}
// Used to make sure that the plugins actually installed, and whether or not
// they actually deployed.
deployed = false
/**
* activatePlugins is a recursive function that installs and enables the plugins
* and their dependencies.
* However, these don't actually do any version pinning, and picks the latest
* versions of the plugins.
*
* @param plugin [Object]
*
* @return nil
*/
def activatePlugin(plugin) {
if (!plugin.isEnabled()) {
plugin.enable()
deployed = true
}
plugin.getDependencies().each {
activatePlugin(pm.getPlugin(it.shortName))
}
}
[
'ant':'1.9', // v1.9
'build-timeout':'1.19', // v1.19
'credentials':'2.1.18', // v2.1.18
'email-ext':'2.63', // v2.63
'github-branch-source':'2.4.1', // v2.4.1
'gradle':'1.29', // v1.29
'jobConfigHistory':'2.19', // v2.19
'ldap':'1.20', // v1.20
'matrix-auth':'2.3', // v2.3
'antisamy-markup-formatter': '1.5', // v1.5
'pam-auth':'1.4', // v1.4
'workflow-aggregator':'2.6', // v2.6
'pipeline-github-lib':'1.0', // v1.0
'ssh-slaves':'1.29.1', // v1.29.1
'subversion':'2.12.1', // v2.12.1
'timestamper':'1.8.10', // v1.8.10
'ws-cleanup':'0.37' // v0.37
].each { plugin, version ->
if (! pm.getPlugin(plugin)) {
VersionNumber versionNumber = new VersionNumber(version)
deployment = uc.getPlugin(plugin, versionNumber).deploy(true)
deployment.get()
}
activatePlugin(pm.getPlugin(plugin))
}
// Do a simple verification that the plugins did deploy, then restart Jankins
if (deployed) {
Jenkins.instance.restart()
}