def install(self, plugins):
"""Install the given plugins, optionally removing unlisted ones.
@params plugins: A whitespace-separated list of plugins to install.
"""
plugins = plugins or ""
plugins = plugins.split()
hookenv.log("Stopping jenkins for plugin update(s)")
host.service_stop("jenkins")
hookenv.log("Installing plugins (%s)" % " ".join(plugins))
host.mkdir(
paths.PLUGINS, owner="jenkins", group="jenkins", perms=0o0755)
existing_plugins = set(glob.glob("%s/*.hpi" % paths.PLUGINS))
try:
installed_plugins = self._install_plugins(plugins)
except:
hookenv.log("Plugin installation failed, check logs for details")
host.service_start("jenkins") # Make sure we don't leave jenkins down
raise
unlisted_plugins = existing_plugins - installed_plugins
if unlisted_plugins:
if hookenv.config()["remove-unlisted-plugins"] == "yes":
self._remove_plugins(unlisted_plugins)
else:
hookenv.log(
"Unlisted plugins: (%s) Not removed. Set "
"remove-unlisted-plugins to 'yes' to clear them "
"away." % ", ".join(unlisted_plugins))
hookenv.log("Starting jenkins to pickup configuration changes")
host.service_start("jenkins")
评论列表
文章目录