Installing the Jenkins Plugin

I wrote Jenkins Groovy Script to install the Jenkins plugin at startup. Groovy scripts are named after Hook, which is used to call my scripts. For instance. init.groovy runs inside the init-hook. This hook starts after initialization.

During initialization, I do not have access to UpdateCenter and cannot install plugins. What other Jenkins Hooks can I use? In my opinion, I need a Hook post launch.

This Script works in the Script console, but not inside the hook after initialization:

import jenkins.model.* def pluginParameter="gitlab-plugin hipchat swarm" def plugins = pluginParameter.split() println(plugins) def instance = Jenkins.getInstance() def pm = instance.getPluginManager() def uc = instance.getUpdateCenter() def installed = false plugins.each { if (!pm.getPlugin(it)) { def plugin = uc.getPlugin(it) if (plugin) { println("Installing " + it) plugin.deploy() installed = true } } } instance.save() if (installed) instance.doSafeRestart() 

I need a hook where the system starts, and uc.getPlugin (it) does not return null.

+6
source share
1 answer

Solved this by asking the Jenkins-irc channel. I needed to initialize the list of site updates UpdateCenter. The result can be found here: blacklabelops / jenkins

+6
source

All Articles