等到Jenkins构建完成 [英] Wait until a Jenkins build is complete

查看:72
本文介绍了等到Jenkins构建完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python 2.7和Jenkins.

I am using Python 2.7 and Jenkins.

我正在用Python编写一些代码,这些代码将执行检入并等待/轮询以完成Jenkins的工作.我想对如何实现这一目标提出一些想法.

I am writing some code in Python that will perform a checkin and wait/poll for Jenkins job to be complete. I would like some thoughts on around how I achieve it.

  1. 在Perforce->中创建签入的Python函数,因为P4具有CLI,可以轻松完成
  2. 检测何时触发构建的Python代码->我有变更列表和作业编号.如何轮询Jenkins API的构建日志,以检查其是否具有适当的变更列表?此步骤的输出是正在执行作业的构建URL
  3. 我如何等待Jenkins工作完成?

我可以使用Jenkins Rest API或Python Jenkins模块中的代码段吗?

Can I use snippets from the Jenkins Rest API or from Python Jenkins module?

推荐答案

您可以查询最后的构建时间戳,以确定构建是否完成.将其与触发生成之前的内容进行比较,并查看更改的时间.要获取时间戳,请在您的工作网址中添加/lastBuild/buildTimestamp

You can query the last build timestamp to determine if the build finished. Compare it to what it was just before you triggered the build, and see when it changes. To get the timestamp, add /lastBuild/buildTimestamp to your job URL

事实上,在您的Jenkins中,将/lastBuild/api/添加到任何Job中,您将看到很多API信息.它甚至具有Python API,但我对此并不熟悉,因此无法进一步帮助您

As a matter of fact, in your Jenkins, add /lastBuild/api/ to any Job, and you will see a lot of API information. It even has Python API, but I not familiar with that so can't help you further

但是,如果您使用的是XML,则可以添加lastBuild/api/xml?depth=0,并且可以在XML内看到<changeSet>对象,其中包含触发构建的修订/提交消息列表

However, if you were using XML, you can add lastBuild/api/xml?depth=0 and inside the XML, you can see the <changeSet> object with list of revisions/commit messages that triggered the build

这篇关于等到Jenkins构建完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆