詹金斯:获取特定日期的构建编号范围 [英] Jenkins: Get build numbers range on a particular day

查看:17
本文介绍了詹金斯:获取特定日期的构建编号范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于数据挖掘的原因,我想获取在特定日期构建的 jenkins 作业的构建编号范围.有没有插件可以完成这个或任何其他可能的方式?

For data mining reasons, I want to get build numbers range of a jenkins job that were built on a particular day. Is there a plugin that accomplishes this or any other possible way?

谢谢,尼克

推荐答案

内置 REST JSON API 将为您提供特定作业的构建列表:http://jenkins:8080/job/JOB_NAME/api/json?tree=builds[fullDisplayName,id,number,timestamp]&pretty=true

The built-in REST JSON API will give you a list of the builds for a particular job: http://jenkins:8080/job/JOB_NAME/api/json?tree=builds[fullDisplayName,id,number,timestamp]&pretty=true

产生类似:

{
  "builds" : [
    {
      "fullDisplayName" : "JOB_NAME #113",
      "id" : "2014-10-31_23-05-20",
      "number" : 113,
      "timestamp" : 1414821920808
    },
    {
      "fullDisplayName" : "JOB_NAME #112",
      "id" : "2014-10-31_17-26-39",
      "number" : 112,
      "timestamp" : 1414801599000
    },
    ....

如果您的构建 ID 是基本日期戳(如上),您可以进行一些字符串处理来过滤结果.否则,您可以将时间戳转换为适当的日期并对其进行过滤.

If your build ids are the basic date-stamp (as above), you can do a little string processing to filter the results. Otherwise, you can convert the timestamp to the appropriate date and filter on that.

大多数 Jenkins 页面底部都有一个 REST API 链接,可提供更多文档,但您经常需要对 API 进行试验以确定它可以提供哪些详细信息.

Most Jenkins pages have a REST API link at the bottom that provides more documentation, though you often need to experiment with the API to figure out what details it can provide.

更新:正如@Nick 发现的那样,builds 结果默认仅限于最新的 100 个元素.根据this Jenkins issue,您可以使用隐藏的allBuilds 元素来检索所有构建".因此,如果您需要 all 构建,请使用:http://jenkins:8080/job/JOB_NAME/api/json?tree=allBuilds[fullDisplayName,id,number,timestamp]&pretty=真

Update: As @Nick discovered, the builds result is limited to the latest 100 elements by default. According to this Jenkins issue, you can use the hidden allBuilds element to retrieve "all builds". So if you need all builds, use: http://jenkins:8080/job/JOB_NAME/api/json?tree=allBuilds[fullDisplayName,id,number,timestamp]&pretty=true

Jenkins 1.568 还在 API 结果中引入了分页,因此可以按范围检索结果.如果您的 Jenkins 版本支持,Jenkins REST API 链接描述了语法.

Jenkins 1.568 also introduced pagination in the API results, so it's possible to retrieve results by range. The Jenkins REST API link describes the syntax if your Jenkins version supports it.

这篇关于詹金斯:获取特定日期的构建编号范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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