rundeck - 通过 Rundeck API 获取作业的最新执行
问题描述
我正在使用最新版本的 Rundeck (3.3.10),并且无法通过 Rest API 获取作业的最新执行。
如果我调用 api/38/job//executions?max=1 如果它仍在运行,它似乎不会带回最新的执行。理想情况下,我还希望能够在单个 API 调用中获得每个作业的最新执行开始时间、结束时间、用户和结果,但我已经辞职,每个作业调用一次 API。似乎没有任何方法可以对从 API 返回的执行进行排序 - 它们似乎首先按状态排序,因此正在运行的作业出现在列表的末尾。
有谁知道解决这个问题的方法?谢谢。
解决方案
Yo can get that information using: executions?status=running&max=1
call.
Script example:
#!/bin/sh
# protocol
protocol="http"
# basic rundeck info
rdeck_host="localhost"
rdeck_port="4440"
rdeck_api="38"
rdeck_token="YRVaZikt64Am85RyLo1nyq8U1Oe4Q8J7 "
# specific api call info
rdeck_job="03f28add-84f2-4013-b8f5-e48feaf5977c"
# api call
curl --location --request GET "$protocol://$rdeck_host:$rdeck_port/api/$rdeck_api/job/$rdeck_job/executions?status=running&max=1" \
--header "Accept: application/json" \
--header "X-Rundeck-Auth-Token: $rdeck_token" \
--header "Content-Type: application/json"
Output:
{
"paging": {
"count": 1,
"total": 1,
"offset": 0,
"max": 1
},
"executions": [
{
"id": 7,
"href": "http://localhost:4440/api/38/execution/7",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/execution/show/7",
"status": "running",
"project": "ProjectEXAMPLE",
"executionType": "user",
"user": "admin",
"date-started": {
"unixtime": 1617304896289,
"date": "2021-04-01T19:21:36Z"
},
"job": {
"id": "03f28add-84f2-4013-b8f5-e48feaf5977c",
"averageDuration": 13796,
"name": "HelloWorld",
"group": "",
"project": "ProjectEXAMPLE",
"description": "",
"href": "http://localhost:4440/api/38/job/03f28add-84f2-4013-b8f5-e48feaf5977c",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/job/show/03f28add-84f2-4013-b8f5-e48feaf5977c"
},
"description": "sleep 20; echo \"hi\"",
"argstring": null,
"serverUUID": "630be43c-e71f-4102-be96-d017dd22233e"
}
]
}
推荐阅读
- javascript - 如何使用相同的 console.log 在不同的行上打印多个数组?
- javascript - Can't figure out why it isn't working, anymore
- postgresql - LOREM 是什么意思?
- node.js - 如何在 fastapi 中处理大量 json 数据响应负载?
- excel - Excel VBA:根据其他工作表的输入自动过滤数据
- k6 - K6 负载测试 - 如何在使用 rps 选项时计算准确的响应时间
- javascript - 当我们必须删除另一个数组中列出的元素时,我不知道该怎么做
- latex - 我们如何在 Overleaf 的长表中换行?
- python - Pandas - 从列中提取值
- python - Google 语音识别不会将数据打印为字符串