【发布时间】: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