def add_node(self, host, executors, labels=()):
"""Add a slave node with the given host name."""
self.wait()
client = self._make_client()
@retry_on_exception(3, 3, exc_type=RETRIABLE)
def _add_node():
if client.node_exists(host):
hookenv.log("Node exists - not adding")
return
hookenv.log("Adding node '%s' to Jenkins master" % host)
# See the "Launch slave agent headlessly" section of the Jenkins
# wiki page about distributed builds:
#
# https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds
launcher = jenkins.LAUNCHER_JNLP
client.create_node(
host, int(executors), host, labels=labels, launcher=launcher)
if not client.node_exists(host):
hookenv.log(
"Failed to create node '%s'" % host, level=ERROR)
return _add_node()
评论列表
文章目录