获取准备阶段批准的AWS管道列表 [英] Get a list of AWS pipelines ready for stage approval

查看:41
本文介绍了获取准备阶段批准的AWS管道列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆