获取准备阶段批准的AWS管道列表 [英] Get a list of AWS pipelines ready for stage approval
问题描述
我有40多个管道需要从开发人员批准到质量检查,然后再由质量检查批准到阶段.我正在使用AWS CLI命令执行脚本.我已经能够对单个管道执行此操作,因为我知道特定的管道已准备就绪,可以批准.
I have 40+ pipelines that I need to approve from dev to QA and then QA to stage. I am working on a script to use AWS CLI commands to do do. I have been able to do that for a single pipeline where I know that the specific pipeline is ready to be approved.
aws codepipeline put-approval-result --cli-input-json file://TestPipeline.json
这就是我如何收集信息以批准单个管道
This is how I gathered the information for the approval for a single pipeline
aws codepipeline get-pipeline-state --name Pipeline-Ready-for-Approval
我想发现的是-有没有一种方法可以使用get-pipeline-state
遍历所有管道并标识阶段名称和操作名称,而无需手动检查每个管道的输出.
What I am trying to find out is - is there a way to loop through all of the pipelines using the get-pipeline-state
and identify the stage name and action name without manually going through output of each of the pipelines.
我可以尝试从aws codepipeline list-pipelines
获取管道名称,以使列表循环通过.
I can try to get the pipeline names from aws codepipeline list-pipelines
to get the list to loop through.
是否可以同时使用bash脚本,awscli和jq?
Is it possible using bash script and awscli and jq together?
谢谢
推荐答案
您可以使用以下方法获得大部分的信息
You can get most of the way there using the following
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
这假定批准操作作为一个阶段中的 first 或 only 操作存在.
This assumes the approval action exists as the first or only action within a stage.
You'll get the output required for the put-approval-result
command
这篇关于获取准备阶段批准的AWS管道列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!