简体   繁体   English

使用 CLI 从 AWS Codepipeline 检索提交 ID

[英]Retrieve commit Id from AWS Codepipeline using CLI

With help of @maafk I was able to get information about each pipeline in this question.在@maafk 的帮助下,我能够获得有关问题中每个管道的信息。 I am now trying to find the commit id for the prod step for each pipeline.我现在正在尝试为每个管道的 prod 步骤查找提交 ID。 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.我有 40 多个管道需要为其获取 commitid,目前,我正在从控制台执行此操作,方法是转到每个管道,单击详细信息并从弹出窗口中复制 commitId。

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.我想自动化这部分并创建一个 output 文件,该文件将为我的 40 多个管道中的每一个提供管道名称和提交 ID。

I am trying to look for it in the json returned by get-pipeline-state but not finding it.我试图在get-pipeline-state返回的 json 中寻找它,但没有找到它。 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?在某些示例中,我看到定义了一个变量,如果这是获取提交 ID 的正确方法,我在哪里可以找到它?

Thank you谢谢

I was able to get the most recent commit id when usig Github as my source provider.当使用 Github 作为我的源提供者时,我能够获得最新的提交 ID。

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这假设 Stage Name 是Source (可以更改为您为 stage 命名的任何名称),并且 state 中的第一个操作是您检索源代码的位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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