1
votes

I'm using AWS and created a CodePipeline using multiple resources (CodeCommit). I properly getting events like this:

{'CodePipeline.job': {'id': '...

In this event I can find the latest commit for each CodeCommit resource but I did not find how I can determine which specific resource triggered the CodePipeline execution. Is it something doable ? Thanks for your help.

3

3 Answers

0
votes

It is not supported yet, but will be in the future. Right now, maybe you could work around by tracking the eventname of StartPipelineExecution in cloudtrail and compare it with the commit time of the source.

0
votes

I am pretty sure you can get the commit message from codepipeline:

aws codepipeline get-pipeline-state --name PIPELINE_NAME

try parsing it using jq, or bash

0
votes

This will tell you which of your resources triggered the pipeline. You will need to give it the pipeline-name and pipelineExecutionId.

aws codepipeline list-pipeline-executions --pipeline-name <YOUR-PIPELINE-NAME> | jq -r '.[] | .[] | select(.pipelineExecutionId=="<PIPELINE-EXEXUTION-ID>") | .trigger.triggerDetail'

I have not tried this in codeBuild, only in the CLI, but you can probably get those needed variables from the ones supplied by codeBuild here.

https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html