api.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:jenkins-charm 作者: jenkinsci 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号