我能够从List-action-executions的输出中得到满足一组过滤器的数组元素,这些元素是在 这个 问题 在返回的对象中,如何选择有最新值的对象作为 lastUpdateTime
属性
这是从链接问题的输出中获得的输入格式。
{
"pipelineExecutionId": "",
"actionExecutionId": "",
"pipelineVersion": 2,
"stageName": "DeployStage",
"actionName": "PromoteToProdApprovalGate",
"startTime": "2020-06-01T22:11:53-04:00",
"lastUpdateTime": "2020-06-01T22:11:53-04:00",
"status": "InProgress",
"input": {
"actionTypeId": {
"category": "Approval",
"owner": "AWS",
"provider": "Manual",
"version": "1"
},
"configuration": {
"CustomData": "Deploy Service to Prod Approval Required for CommitID=#{SourceBuildVariables.BB_COMMIT_ID}",
"ExternalEntityLink": "#{SourceBuildVariables.BB_URL}",
"NotificationArn": "arn:aws:sns:us-east-1:"
},
"resolvedConfiguration": {
"CustomData": "Deploy Service to Prod Approval Required for CommitID=xxx1",
"ExternalEntityLink": "http://",
"NotificationArn": "arn:aws:sns:us-east-1:"
},
"region": "us-east-1",
"inputArtifacts": []
},
"output": {
"outputArtifacts": [],
"outputVariables": {}
}
}
{
"pipelineExecutionId": "",
"actionExecutionId": "",
"pipelineVersion": 1,
"stageName": "DeployStage",
"actionName": "PromoteToProdApprovalGate",
"startTime": "2020-03-31T23:29:14.479000-04:00",
"lastUpdateTime": "2020-04-03T19:04:51.646000-04:00",
"status": "Succeeded",
"input": {
"actionTypeId": {
"category": "Approval",
"owner": "AWS",
"provider": "Manual",
"version": "1"
},
"configuration": {
"CustomData": "Deploy Service to Prod Approval Required for CommitID=#{SourceBuildVariables.BB_COMMIT_ID}",
"ExternalEntityLink": "#{SourceBuildVariables.BB_URL}",
"NotificationArn": "arn:aws:sns:us-east-1:"
},
"resolvedConfiguration": {
"CustomData": "Deploy Service to Prod Approval Required for CommitID=xxx2",
"ExternalEntityLink": "http://",
"NotificationArn": "arn:aws:sns:us-east-1:"
},
"region": "us-east-1",
"inputArtifacts": []
},
"output": {
"outputArtifacts": [],
"executionResult": {
"externalExecutionId": ",
"externalExecutionSummary": "Approved by arn:aws:sts:"
},
"outputVariables": {}
}
}
{
"pipelineExecutionId": "",
"actionExecutionId": "",
"pipelineVersion": 1,
"stageName": "DeployStage",
"actionName": "PromoteToProdApprovalGate",
"startTime": "2020-03-18T21:10:25.541000-04:00",
"lastUpdateTime": "2020-03-25T21:10:25.965000-04:00",
"status": "Failed",
"input": {
"actionTypeId": {
"category": "Approval",
"owner": "AWS",
"provider": "Manual",
"version": "1"
},
"configuration": {
"CustomData": "Deploy Service to Prod Approval Required for CommitID=#{SourceBuildVariables.BB_COMMIT_ID}",
"ExternalEntityLink": "#{SourceBuildVariables.BB_URL}",
"NotificationArn": "arn:aws:sns:us-east-1"
},
"resolvedConfiguration": {
"CustomData": "Deploy Service to Prod Approval Required for CommitID=xxx3",
"ExternalEntityLink": "http://",
"NotificationArn": "arn:aws:sns:us-east-1:"
},
"region": "us-east-1",
"inputArtifacts": []
},
"output": {
"outputArtifacts": [],
"executionResult": {
"externalExecutionId": ""
},
"outputVariables": {}
}
}
{
"pipelineExecutionId": "",
"actionExecutionId": "",
"pipelineVersion": 1,
"stageName": "DeployStage",
"actionName": "PromoteToProdApprovalGate",
"startTime": "2020-03-09T19:23:43.637000-04:00",
"lastUpdateTime": "2020-03-10T14:48:30.069000-04:00",
"status": "Failed",
"input": {
"actionTypeId": {
"category": "Approval",
"owner": "AWS",
"provider": "Manual",
"version": "1"
},
"configuration": {
"CustomData": "Deploy Service to Prod Approval Required for CommitID=#{SourceBuildVariables.BB_COMMIT_ID}",
"ExternalEntityLink": "#{SourceBuildVariables.BB_URL}",
"NotificationArn": "arn:aws:sns:us-east-1"
},
"resolvedConfiguration": {
"CustomData": "Deploy Service to Prod Approval Required for CommitID=xxx4",
"ExternalEntityLink": "http://",
"NotificationArn": "arn:aws:sns:us-east-1:"
},
"region": "us-east-1",
"inputArtifacts": []
},
"output": {
"outputArtifacts": [],
"executionResult": {
"externalExecutionId": "",
"externalExecutionSummary": ""
},
"outputVariables": {}
}
}
谢谢你
你可以使用 max_by
并提供一个路径表达式,使用它可以对对象数组进行排序。
.actionExecutionDetails
| max_by(.startTime)
这在功能上等同于通过字段进行排序,并获得数组中的最后一个元素。默认情况下 sort()
函数对这些值进行升序排序,并进行 不 提供一个参数来进行降序排序。
.actionExecutionDetails
| sort_by(.startTime)
| last