获取准备阶段批准的 AWS 管道列表

Get a list of AWS pipelines ready for stage approval

我有 40 多个管道需要批准,从开发到 QA,然后从 QA 到阶段。我正在编写一个脚本来使用 AWS CLI 命令来做。我已经能够为单个管道执行此操作,我知道该特定管道已准备好获得批准。

aws codepipeline put-approval-result --cli-input-json file://TestPipeline.json 

这就是我收集单个管道审批信息的方式

aws codepipeline get-pipeline-state --name Pipeline-Ready-for-Approval 

我想知道的是 - 有没有一种方法可以使用 get-pipeline-state 遍历所有管道并识别阶段名称和操作名称,而无需手动遍历每个管道的输出.

我可以尝试从 aws codepipeline list-pipelines 获取管道名称以获取要循环的列表。

是否可以将 bash 脚本与 awscli 和 jq 一起使用?

谢谢

您可以使用以下方式到达那里的大部分路线

pipelines=$(aws codepipeline list-pipelines --query 'pipelines[].name' --output text)

for p in pipelines; do
    aws codepipeline get-pipeline-state \
        --name $p \
        --query 'stageStates[?latestExecution.status==`InProgress`].{stageName:stageName,actionName:actionStates[0].actionName,token:actionStates[0].latestExecution.token}'
done

这假定批准操作作为阶段中的第一个个操作存在。

您将获得 put-approval-result 命令所需的输出