Azure DevOps API 运行 和构建开始时间之间的差异
Azure DevOps API Discrepancy between Run and Build Start Times
我正在收集有关 Azure DevOps 构建持续时间的统计信息。我正在使用多个 Azure DevOps API 端点并注意到管道和构建响应有效负载之间存在差异。虽然两个端点 return 相同构建 结束时间 ,但 pipeline run endpoint createDate
value is consistently occurring earlier than the build endpoint startTime
值。
直觉上,我认为构建的开始时间应该与构建的开始时间平行运行。
我正在使用这两个端点从 相同的构建 中检索数据,其中包含一个 runId
参数 74 和相应的 buildId
参数 2731。
正在调用 {AzureDevOps}/{project}/_apis/pipelines/74/runs?{API_v6}
return 2020-10-14T19:43:55.4471062Z 的 createDate
值和 2020-10-14T19:49 的 finishedDate
值: 29.1295883Z。调用 {AzureDevOps}/{project}/_apis/build/builds/2731?{API_v6}
returns 2020-10-14T19:47:53.1064066Z 的 startTime
值和 2020-10-14T19:49:29.1295883Z 的 finishTime
值。
高于 createDate
的值比 startTime
值早 4 分钟开始。造成这种差异的原因是什么?
我也为此做了测试,我得到了这些:
- 构建
"startTime": "2020-10-15T02:40:20.4766161Z",
"finishTime": "2020-10-15T02:41:02.1443416Z",
- 管道
"createdDate": "2020-10-15T02:40:09.5783822Z",
"finishedDate": "2020-10-15T02:41:02.1443416Z",
在我的例子中,我在 startTime
/createdDate
中得到了不同的值,这对我来说意味着
startTime
- 执行构建的时间。我检查了日志,第一个条目是 2020-10-15T02:40:22.1518676Z ##[section]Starting: Job
createdDate
- 创建管道 运行 的时间,因此它还包括等待可用作业的时间
我对 finishTime
和 finishedDate
的结果相同,但同样适用于此。所以第二个可能包括解除分配代理的时间。日志中的最后一项是
2020-10-15T02:41:00.1014543Z ##[section]Finishing: Job
,小于 API.
中的值
查看 timeline
端点:
可能会得到更准确的结果
https://dev.azure.com/{{organization}}/{{project}}/_apis/build/builds/7512/timeline?api-version=6.0
例如,您可以查看阶段的执行时间:
"previousAttempts": [],
"id": "96ac2280-8cb4-5df5-99de-dd2da759617d",
"parentId": null,
"type": "Stage",
"name": "__default",
"startTime": "2020-10-15T02:40:22.1466667Z",
"finishTime": "2020-10-15T02:41:02.19Z",
您还可以使用日志端点和解析响应来获取第一个和最后一个条目。而且我知道这不是优雅的解决方案,但我会为此做出决定,因为它给出了最窄的时间范围。对于我来说,这些统计数据对于衡量处理管道的实时花费很重要。
管道 运行 端点 createDate 值等于构建端点 queueTime 值而不是 startTime 值。
当您 运行 管道时,管道不会立即启动。例如,如果您的组织中没有足够的并行作业,它将等待代理。您还可以从管道日志中找到:
如果您的管道尚未启动,startTime 将不会出现在 Get Build REST 的响应中 API。但是你仍然可以获得queueTime和createdDate。
我正在收集有关 Azure DevOps 构建持续时间的统计信息。我正在使用多个 Azure DevOps API 端点并注意到管道和构建响应有效负载之间存在差异。虽然两个端点 return 相同构建 结束时间 ,但 pipeline run endpoint createDate
value is consistently occurring earlier than the build endpoint startTime
值。
直觉上,我认为构建的开始时间应该与构建的开始时间平行运行。
我正在使用这两个端点从 相同的构建 中检索数据,其中包含一个 runId
参数 74 和相应的 buildId
参数 2731。
正在调用 {AzureDevOps}/{project}/_apis/pipelines/74/runs?{API_v6}
return 2020-10-14T19:43:55.4471062Z 的 createDate
值和 2020-10-14T19:49 的 finishedDate
值: 29.1295883Z。调用 {AzureDevOps}/{project}/_apis/build/builds/2731?{API_v6}
returns 2020-10-14T19:47:53.1064066Z 的 startTime
值和 2020-10-14T19:49:29.1295883Z 的 finishTime
值。
高于 createDate
的值比 startTime
值早 4 分钟开始。造成这种差异的原因是什么?
我也为此做了测试,我得到了这些:
- 构建
"startTime": "2020-10-15T02:40:20.4766161Z",
"finishTime": "2020-10-15T02:41:02.1443416Z",
- 管道
"createdDate": "2020-10-15T02:40:09.5783822Z",
"finishedDate": "2020-10-15T02:41:02.1443416Z",
在我的例子中,我在 startTime
/createdDate
中得到了不同的值,这对我来说意味着
startTime
- 执行构建的时间。我检查了日志,第一个条目是2020-10-15T02:40:22.1518676Z ##[section]Starting: Job
createdDate
- 创建管道 运行 的时间,因此它还包括等待可用作业的时间
我对 finishTime
和 finishedDate
的结果相同,但同样适用于此。所以第二个可能包括解除分配代理的时间。日志中的最后一项是
2020-10-15T02:41:00.1014543Z ##[section]Finishing: Job
,小于 API.
查看 timeline
端点:
https://dev.azure.com/{{organization}}/{{project}}/_apis/build/builds/7512/timeline?api-version=6.0
例如,您可以查看阶段的执行时间:
"previousAttempts": [],
"id": "96ac2280-8cb4-5df5-99de-dd2da759617d",
"parentId": null,
"type": "Stage",
"name": "__default",
"startTime": "2020-10-15T02:40:22.1466667Z",
"finishTime": "2020-10-15T02:41:02.19Z",
您还可以使用日志端点和解析响应来获取第一个和最后一个条目。而且我知道这不是优雅的解决方案,但我会为此做出决定,因为它给出了最窄的时间范围。对于我来说,这些统计数据对于衡量处理管道的实时花费很重要。
管道 运行 端点 createDate 值等于构建端点 queueTime 值而不是 startTime 值。
当您 运行 管道时,管道不会立即启动。例如,如果您的组织中没有足够的并行作业,它将等待代理。您还可以从管道日志中找到:
如果您的管道尚未启动,startTime 将不会出现在 Get Build REST 的响应中 API。但是你仍然可以获得queueTime和createdDate。