在documentation 之后,您可以在API 调用中使用recentFilter 参数,我做了一个示例(最后我添加了jq 命令来“美化”默认输出):
#!/bin/sh
# protocol
protocol="http"
# basic rundeck info
rdeck_host="localhost"
rdeck_port="4440"
rdeck_api="36"
rdeck_token="ni28E9M5s5H0s3kyCKQ0tbfPCI8jNZS1"
# specific api call info
rdeck_project="ProjectEXAMPLE"
time="1h"
# api call
curl -s --location --request GET "$protocol://$rdeck_host:$rdeck_port/api/$rdeck_api/project/$rdeck_project/executions?recentFilter=$time" \
--header "Accept: application/json" \
--header "X-Rundeck-Auth-Token: $rdeck_token" \
--header "Content-Type: application/json" | jq
输出:
{
"paging": {
"count": 2,
"total": 2,
"offset": 0,
"max": 20
},
"executions": [
{
"id": 2,
"href": "http://localhost:4440/api/36/execution/2",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/execution/show/2",
"status": "succeeded",
"project": "ProjectEXAMPLE",
"executionType": "scheduled",
"user": "admin",
"date-started": {
"unixtime": 1608296400032,
"date": "2020-12-18T13:00:00Z"
},
"date-ended": {
"unixtime": 1608296400374,
"date": "2020-12-18T13:00:00Z"
},
"job": {
"id": "f2a837d2-1a9c-4387-89d7-0243bbfe6ba9",
"averageDuration": 590,
"name": "HelloWorld",
"group": "",
"project": "ProjectEXAMPLE",
"description": "",
"href": "http://localhost:4440/api/36/job/f2a837d2-1a9c-4387-89d7-0243bbfe6ba9",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/job/show/f2a837d2-1a9c-4387-89d7-0243bbfe6ba9"
},
"description": "echo \"hi\"",
"argstring": null,
"serverUUID": "94ac86b1-56e9-4bc3-9a4c-50cd7c8a5b59",
"successfulNodes": [
"localhost"
]
},
{
"id": 1,
"href": "http://localhost:4440/api/36/execution/1",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/execution/show/1",
"status": "succeeded",
"project": "ProjectEXAMPLE",
"executionType": "scheduled",
"user": "admin",
"date-started": {
"unixtime": 1608295800075,
"date": "2020-12-18T12:50:00Z"
},
"date-ended": {
"unixtime": 1608295800914,
"date": "2020-12-18T12:50:00Z"
},
"job": {
"id": "f2a837d2-1a9c-4387-89d7-0243bbfe6ba9",
"averageDuration": 590,
"name": "HelloWorld",
"group": "",
"project": "ProjectEXAMPLE",
"description": "",
"href": "http://localhost:4440/api/36/job/f2a837d2-1a9c-4387-89d7-0243bbfe6ba9",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/job/show/f2a837d2-1a9c-4387-89d7-0243bbfe6ba9"
},
"description": "echo \"hi\"",
"argstring": null,
"serverUUID": "94ac86b1-56e9-4bc3-9a4c-50cd7c8a5b59",
"successfulNodes": [
"localhost"
]
}
]
}