詹金斯插件安装 [英] Jenkins Plugin Installation
问题描述
我在启动时编写了一个Jenkins Groovy Script来安装Jenkins插件。 Groovy脚本以用于调用脚本的Hook命名。例如。 init.groovy在init-Hook内被触发。这个Hook在后期初始化时触发。
在初始化期间,我无法访问UpdateCenter,也无法安装插件。我还可以使用其他Jenkins Hooks?在我看来,我需要一个启动后的Hook。
这个脚本在脚本控制台中工作,但不在post-initialization hook中:
import jenkins.model。*
$ b def pluginParameter =gitlab-plugin hipchat swarm
def plugins = pluginParameter.split()
println(插件)
def instance = Jenkins.getInstance()
def pm = instance.getPluginManager()
def uc = instance.getUpdateCenter()
def已安装= false
plugins.each {
if(!pm.getPlugin(it)){
def plugin = uc.getPlugin(it)
if(plugin) {
println(安装+它)
plugin.deploy()
installed = true
}
}
}
instance.save()
if(installed)
instance.doSafeRestart()
解决了这个问题通过询问jenkins-irc频道。我需要初始化UpdateCenter的更新站点列表。结果可以在这里找到:
blacklabelops / jenkins
I have written a Jenkins Groovy Script for installing Jenkins plugin at startup. Groovy scripts are named after the Hook that is used to invoke my scripts. E.g. init.groovy is triggered inside the init-Hook. This Hook is triggered in post-initialization.
During initialization I have no access to the UpdateCenter and cannot install the plugins. What other Jenkins Hooks can I use? In my opinion I need a post-startup Hook.
This script works in script console but not inside post-initialization hook:
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 system is started and uc.getPlugin(it) does not return null.
Solved this by asking the jenkins-irc channel. I needed to initialize the UpdateCenter's list of update sites. The result can be found here: blacklabelops/jenkins
这篇关于詹金斯插件安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!