简体   繁体   中英

Retrieve commit Id from AWS Codepipeline using CLI

With help of @maafk I was able to get information about each pipeline in this question. I am now trying to find the commit id for the prod step for each pipeline. I have 40+ pipelines that I need to get commitids for and currently, i am doing it from console, by going to each pipeline, click on the details and copy the commitId from the pop-up.

I would like to automate this part and create an output file, that will have the pipeline name and the commit id for each of my 40+ pipelines.

I am trying to look for it in the json returned by get-pipeline-state but not finding it. In some of the examples, I have seen there is a variable defined, where do I find that, if that is the correct way to get commit id?

Thank you

I was able to get the most recent commit id when usig Github as my source provider.

aws codepipeline get-pipeline-state \
    --name my-pipeline-name \
    --query 'stageStates[?stageName==`Source`].actionStates[0].currentRevision.revisionId' \
    --output text

This assumes the Stage Name is Source (can change to whatever you've named your stage), and that the first action in that state is where you retrieve the source code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM