Diana Kerrala
Diana Kerrala

Reputation: 77

Find which files were updated in a commit in AWS CodePipeline

I am triggering AWS CodePipeline with a PR commit through Bitbucket. Is there any way I can find which files were updated/created with the latest commit?

I looked into the Environment Variables and I looked into the pipeline's details and history CLI commands: $ aws codepipeline list-pipeline-executions --pipeline-name <name> and $ aws codepipeline get-pipeline-state --name <name> but they don't have the information I need.

Why do I need this? The pipeline triggers one or more Airflow DAGs and listens to their status. We include the DAG name(s) in the branch name, we parse it using CODEBUILD_WEBHOOK_HEAD_REF and we trigger the DAG(s). This is error-prone, and since the DAG names match their filename we would like to extract them automatically.

Is it something doable? Thanks for your help!

Upvotes: 0

Views: 1643

Answers (1)

Lucasz
Lucasz

Reputation: 1218

You can get the commit hash from the pipeline execution. when using cli:

aws codepipeline list-pipeline-executions --pipeline-name <pipeline-name>

you get a list of executions, the first execution is the latest one.

pipelineExecutionSummaries: [ 
    { ...
       sourceRevisions: [
         {
             ...
             revisionId: "<commit-hash>"
          }
        ]
    }
...
]

then when you have the commit hash you can get the files that are modified in that commit

git diff-tree --stat <commit-hash>

further logic depending on your application you can handle when you got the files that are modified.

Upvotes: 3

Related Questions