Build History API
您可以在 JSON 文件中接收关于您的构建数据。这允许您使用第三方工具获取并在仪表板中查看这些数据,以及存储以供参考和分析。
可按时间、构建组和其他字段过滤数据。此 API 需要一个 API Key。
请注意,Incredibuild 仅在我们的数据库中存储最后 200,000 个构建。
请求
端点
访问 https://<coordinator IP>:8000/api/builds?coordinatorId=<coordinator ID>&version=<API version>&<other filters>
该版本是 Incredibuild API 版本对于构建数据 API,目前仅支持 1.3.0 版。
标题
该请求必须包含一个带有名为 client-api-key 密钥的标题和 API 密钥值字符串。
端点筛选器:
您可以向请求端点添加以下任意筛选器来限制结果:
字段 | 值 | 值 |
---|---|---|
buildStartTimeFrom | 仅包括在此时间之前开始的构建 | ISO 格式。例如:2022-09-28T16:01:29.000 |
buildEndTimeTo | 仅包括在此时间之前结束的构建 | ISO 格式。例如:2022-09-28T16:01:29.000 |
initiatorID | 仅包括由特定 Initiator 启动的构建 | 字符串 |
buildGroup | 仅包括由特定 Build Group 中的 Initiator 运行的构建 | 字符串 |
buildTitle | 仅包括具有指定标题的构建 | 字符串 |
buildStatus |
仅包括与特定状态匹配的构建 |
{a,b,c,d} |
buildDurationFrom |
仅包括至少为该长度的构建 |
整数(秒) |
buildDurationTo |
仅包括短于该值的构建 |
整数(秒) |
buildType |
仅包括与特定构建类型匹配的构建 |
{Build, Clean, Rebuild, Unknown} |
示例:
-
返回所有构建:
访问 https://10.132.15.166:8000/api/builds?coordinatorId=12345&version=1.3.0
-
返回在特定时间之后启动的构建:
访问 https://10.132.15.166:8000/api/builds?coordinatorId=12345&version=1.3.0&buildStartTimeFrom=2023-08-17T16:01:29.000Z
-
返回从 Default Build Group 运行的构建:
访问 https://10.132.15.166:8000/api/builds?coordinatorId=12345&version=1.3.0&buildGroup=Default
如果您的结果返回超过 300 个构建,您将看到 totalCount 大于 300,但 buildsCount 值为300(如下例所示)。如需查看下一个 300,请复制 nextPageToken 值并用于另一个请求,如下所示:
GET https://10.132.15.166:8000/api/builds?coordinatorId=12345&version=1.3.0&nextPageToken="<value in JSON below>"
响应
响应为包含多达 300 个构建的 JSON 文件。
字段 | 描述 |
---|---|
totalCount | 与请求匹配的构建总数 |
buildsCount | 此 JSON 中包含的构建数量。如果该数量小于 totalCount,则代表有 300 多个构建,并且不可能包含在一个 JSON 中。如需查看下一个 300,请复制 nextPageToken 并用作另一个请求的参数。例如:GET https://10.132.15.166:8000/api/builds?coordinatorId=12345&version=1.3.0&nextPageToken="NjAw" |
nextPageToken | 请参阅 buildsCount |
构建 |
文件中包含的构建数组 |
coordinatorId |
与此构建关联的 Coordinator ID |
buildId |
构建 ID |
initiatorId |
启动构建的代理 ID |
startTime |
开始构建的时间 |
endTime |
结束构建的时间 |
duration |
构建长度,秒 |
buildCaption |
您为描述此构建而添加的元数据(可选) |
buildStatus |
构建完成时的状态 |
helpers |
参与此构建的 Helpers 列表 |
totalWorkingHelpers |
协助此构建的唯一 Helpers 总数 |
maxInitiatorCores |
用于运行此构建的最大 Initiator 内核数 |
avgInitiatorCores |
用于运行此构建的平均 Initiator 内核数 |
maxConcurrentWorkingHelpers |
在此构建期间一次工作应用的最大唯一 Helpers 数量 |
avgConcurrentWorkingHelpers |
在此构建期间一次工作应用的平均唯一 Helpers 数量 |
avgBusyHelperCores |
在此构建期间一次工作应用的平均 Helper 内核数 |
maxBusyHelperCores |
在此构建期间一次工作应用的最大 Helper 内核数 |
avgBusyCloudHelperCores |
在此构建期间一次工作应用的平均 Cloud Helper 内核数 |
maxBusyCloudHelperCores |
在此构建期间一次工作应用的最大 Cloud Helper 内核数 |
maxNeededHelperCores |
请求的最大 Helper 内核数 |
avgNeededHelperCores |
请求的平均 Helper 内核数 |
numberOfLocalTasks |
针对此构建在 Initiator 上执行的任务总数 |
numberOfRemoteTasks |
远程执行的任务总数 |
numberOfCloudTasks |
在云机器上远程执行的任务总数 |
remoteCoreTime |
用于远程(物理和云)执行任务的总时间(秒) |
coreLimit |
每次构建允许的最大 Helper 内核数设置 |
createdAt |
生成此响应的 API 调用的日期和时间。 |
字段 | 描述 |
响应示例
以下示例显示了将包含在此 JSON 中的首个构建:
{
"totalCount":400
"buildsCount":300
"nextPageToken":"NjAw"
"builds": [
{
"coordinatorId": "c407c0b4-b257-490a-91da-70b7bb5f0c8f",
"buildId": "{0312b602-8d53-4443-afe5-2bd9f00c33d7}",
"initiatorId": "64b4d714-fcde-4768-82ac-cdbdfbfa5343",
"initiatorName": "Initiator#313",
"startTime": "2023-08-18T20:05:42.708Z",
"endTime": "2023-08-18T22:41:27.097Z",
"duration": 9344389,
"buildGroup": "Build Group 17",
"buildCaption": "Build Title 5",
"buildStatus": "Failure",
"buildType": "Rebuild",
"helpers": [
"helper0",
"helper1",
"helper2",
"helper3",
"helper4",
"helper5",
"helper6",
"helper7",
"helper8",
"helper9",
"helper10",
"helper11",
"helper12",
"helper13",
"helper14",
"helper15",
"helper16",
"helper17",
"helper18",
"helper19",
"helper20"
],
"totalWorkingHelpers": 9,
"maxInitiatorCores": 48,
"avgInitiatorCores": 94,
"maxConcurrentWorkingHelpers": 97,
"avgConcurrentWorkingHelpers": 91,
"avgConcurrentBusyHelpers": 1,
"maxConcurrentBusyHelpers": 30,
"avgConcurrentBusyCloudHelpers": 50,
"maxConcurrentBusyCloudHelpers": 59,
"maxNeededHelperCores": 29,
"avgNeededHelperCores": 84,
"numberOfLocalTasks": 36,
"numberOfRemoteTasks": 83,
"numberOfCloudTasks": 94,
"remoteCoreTime": 78,
"coreLimit": 11,
"createdAt": "2023-08-20T07:27:30.425Z"
}]
从数据中提取更多信息
下载构建历史记录后,您可以在自己选择的数据库中访问它们。这样,您就可以查询数据,了解更多信息。下面是一些实例查询:
select initiator_id, count(distinct build_id) as builds from builds b group by initiator_id
select build_id , total_working_helpers from builds b
select date(start_time) as date, sum(remote_core_time)/60000 as total_remote_minutes
from builds b
group by 1
order by 1
select date(start_time) as date, count(distinct initiator_id) as unique_initiators
from builds b
group by 1
order by 1
WITH RECURSIVE split_cte (start_time ,build_id , helpers , rest) AS (
SELECT
start_time,
build_id ,
SUBSTR(SUBSTRING(helpers,2,LENGTH(helpers)-1) , 1, INSTR(helpers, ',')-2),
SUBSTR(helpers , INSTR(helpers, ',')+1)
FROM builds
WHERE total_working_helpers > 1
UNION ALL
SELECT
start_time,
build_id ,
SUBSTR(rest, 1, INSTR(rest, ',')-1),
SUBSTR(rest, INSTR(rest, ',')+1)
FROM split_cte
WHERE INSTR(rest, ',') > 0
UNION ALL
SELECT
start_time,
build_id ,
substring(rest,1,LENGTH(rest)-1),
NULL
FROM split_cte
WHERE INSTR(rest, ',') = 0
)
-- Select the split values
select date(start_time) as date, count(distinct helpers)
from
(SELECT start_time,build_id, helpers
FROM split_cte
UNION ALL
SELECT start_time,build_id, helpers
FROM split_cte
WHERE rest IS NOT NULL
union all
select start_time,build_id,SUBSTRING(helpers,2,LENGTH(helpers)-2)
from builds
where total_working_helpers=1)
group by date(start_time)
order by 1
SELECT date(start_time) as date,count(build_id) as builds from builds
where build_status = 'SystemErrorOrUserInterrupt'
group by date(start_time)
select build_group, date(start_time) as date, count(build_id)
from builds b
group by build_group, date(start_time)
order by 1,2
select build_group , count(distinct initiator_id) as unique_initiators
from builds b
group by 1
WITH RECURSIVE split_cte (build_group ,build_id , helpers , rest) AS (
SELECT
build_group ,
build_id ,
SUBSTR(SUBSTRING(helpers,2,LENGTH(helpers)-1) , 1, INSTR(helpers, ',')-2),
SUBSTR(helpers , INSTR(helpers, ',')+1)
FROM builds
WHERE total_working_helpers > 1
UNION ALL
SELECT
build_group,
build_id ,
SUBSTR(rest, 1, INSTR(rest, ',')-1),
SUBSTR(rest, INSTR(rest, ',')+1)
FROM split_cte
WHERE INSTR(rest, ',') > 0
UNION ALL
SELECT
build_group,
build_id ,
substring(rest,1,LENGTH(rest)-1),
NULL
FROM split_cte
WHERE INSTR(rest, ',') = 0
)
-- Select the split values
select build_group, count(distinct helpers)
from
(SELECT build_group,build_id, helpers
FROM split_cte
UNION ALL
SELECT build_group,build_id, helpers
FROM split_cte
WHERE rest IS NOT NULL
union all
select build_group,build_id,SUBSTRING(helpers,2,LENGTH(helpers)-2)
from builds
where total_working_helpers=1)
group by build_group
WITH RECURSIVE split_cte (start_time ,build_id , helper , rest) AS (
SELECT
start_time,
build_id ,
SUBSTR(SUBSTRING(helpers,2,LENGTH(helpers)-1) , 1, INSTR(helpers, ',')-2),
SUBSTR(helpers , INSTR(helpers, ',')+1)
FROM builds
WHERE total_working_helpers > 1
UNION ALL
SELECT
start_time,
build_id ,
SUBSTR(rest, 1, INSTR(rest, ',')-1),
SUBSTR(rest, INSTR(rest, ',')+1)
FROM split_cte
WHERE INSTR(rest, ',') > 0
UNION ALL
SELECT
start_time,
build_id ,
substring(rest,1,LENGTH(rest)-1),
NULL
FROM split_cte
WHERE INSTR(rest, ',') = 0
)
-- Select the split values
select date(start_time) as date, helper, count(distinct build_id) as builds
from
(SELECT start_time,build_id, helper
FROM split_cte
UNION ALL
SELECT start_time,build_id, helper
FROM split_cte
WHERE rest IS NOT NULL
union all
select start_time,build_id,SUBSTRING(helpers,2,LENGTH(helpers)-2)
from builds
where total_working_helpers=1)
group by date(start_time),helper
order by 1, 3 desc
with recursive builds_active_seconds (date,build_id,start_timestamp, sec, end_timestamp) as (
select date(start_time),build_id ,min(datetime(start_time)),min(datetime(start_time)),max(datetime(end_time))
from builds b
group by date(start_time),2
union all
select date,build_id ,start_timestamp,datetime(sec,'+1 second'),end_timestamp
from builds_active_seconds
where sec<end_timestamp
)
select date,count(distinct sec)/60 as grid_active_minutes
from builds_active_seconds
group by 1
SELECT distinct date(start_time) as date,build_status,
count(build_id) over (partition by date(start_time),build_status)*1.00/count(build_id) over (partition by (date(start_time))) as percentage_of_daily_builds
from builds b
order by 1,2
with recursive builds_active_seconds (date,build_id,start_timestamp, sec, end_timestamp) as (
select date(start_time),build_id ,min(datetime(start_time)),min(datetime(start_time)),max(datetime(end_time))
from builds b
group by date(start_time),2
union all
select date,build_id ,start_timestamp,datetime(sec,'+1 second'),end_timestamp
from builds_active_seconds
where sec<end_timestamp
),
concurrent_build_count as (select date,sec,count(build_id) as concurrent_builds
from builds_active_seconds
group by 1,2)
select date,max(concurrent_builds) as max_concurrent_builds
from concurrent_build_count
group by 1