使用Hudson/Jenkins API确定给定的作业当前是否正在运行 [英] Determine if given job is currently running using Hudson/Jenkins API

查看:254
本文介绍了使用Hudson/Jenkins API确定给定的作业当前是否正在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有API可以确定给定作业当前是否正在运行?

Is there an API to determine whether a given job is currently running or not?

理想情况下,我还希望能够确定其估计的完成百分比,并获取SVN版本号的详细信息并提交评论!

Ideally, I'd also like to be able to determine its estimated % complete and get the details of the SVN revision number and commit comment too!

我找到了答案. http://host/job/project/lastBuild/api/在某处几乎满足了我的所有需求!如果您启动手动构建,它不会告诉您SCM变更集,但这很有意义.它仍然会告诉您最新的SCM版本,所以很好.总而言之,对于我现在的目的来说已经足够好了.

I found the answer. http://host/job/project/lastBuild/api/ has almost all of what I need in it somewhere! If you kick off a manual build, it won't tell you the SCM changesets, but that makes sense. It does still tell you the latest SCM revision though, so that's good. All in all, good enough for my purposes right now.

推荐答案

正如gareth_bowles和Sagar所说,使用Jenkins API是了解方法. 如果将深度设为1,您将看到您要寻找的内容:

As gareth_bowles and Sagar said, using the Jenkins API is the way to know. If you put the depth to 1, you will see what you're looking for:

http://host/job/project/lastBuild/api/xml?depth=1

您会看到有一个<building>标记可以告诉您该版本是否正在运行

You will see there's a <building> tag to tell if that build is running

...
<build>
  <action>
    <cause>
        <shortDescription>Started by user Zageyiff</shortDescription>
        <userId>Zageyiff</userId>
        <userName>Zageyiff</userName>
    </cause>
  </action>
  <building>true</building>
  <duration>0</duration>
  <estimatedDuration>-1</estimatedDuration>
  <fullDisplayName>Project #12</fullDisplayName>
  <id>2012-08-24_08-58-45</id>
  <keepLog>false</keepLog>
  <number>12</number>
  <timestamp>123456789</timestamp>
  <url>
        http://host/job/project/12
  </url>
  <builtOn>master</builtOn>
  <changeSet/>
  <mavenVersionUsed>3.0.3</mavenVersionUsed>
</build>
...

这篇关于使用Hudson/Jenkins API确定给定的作业当前是否正在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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