【问题标题】:What is the python-jenkins wrapper commands for cancelling queued build and rebuild a previous build?什么是用于取消排队构建和重建先前构建的 python-jenkins 包装器命令?
【发布时间】:2021-04-27 09:57:12
【问题描述】:

我正在使用 python-jenkins 包装器来操作我的 python 项目中的 Jenkins 作业。大多数操作,如构建作业、删除构建等,文档中都有一个 python 命令,但是没有这样的命令可用于使用 python 作为后端重建旧构建,有人可以吗?推荐一段我可以使用的代码?

另一个问题是python-jenkins包的cancel_queue() api,它需要一个job id作为参数,我在哪里可以找到那个id?

    def cancel_queue(self, id):
        '''Cancel a queued build.

        :param id: Jenkins job id number for the build, ``int``
        '''
        # Jenkins seems to always return a 404 when using this REST endpoint
        # https://issues.jenkins-ci.org/browse/JENKINS-21311
        try:
            self.jenkins_open(
                requests.Request(
                    'POST', self._build_url(CANCEL_QUEUE, locals()),
                    headers={'Referer': self.server}))
        except NotFoundException:
            # Exception is expected; cancel_queue() is a best-effort
            # mechanism, so ignore it
            pass

这是cancel_queue api的代码,这是哪个id? 有没有其他方法可以一次取消队列中的构建?

谢谢

【问题讨论】:

    标签: python jenkins google-api-python-client


    【解决方案1】:

    所以我很难学到这一点,Jenkins 有自己的 queue_id,我们可以使用 python-jenkins 包装器读取它。 例如:

    server = jenkins.Jenkins(URL, username=USER, password=PASSWORD)
    queue_id = server.get_build_info(job_name, build_no)['queueId']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-14
      • 2019-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-23
      相关资源
      最近更新 更多