github-codebuild-logs icon indicating copy to clipboard operation
github-codebuild-logs copied to clipboard

Never a PR Build

Open rehanvdm opened this issue 3 years ago • 5 comments

I am not sure why but the sourceVersion field in the JSON event never starts with pr/.

https://github.com/jlhood/github-codebuild-logs/blob/86f8fd60892c00fea1ddbefd741ae35292707e0a/src/build.py#L30

A sample from my event as output when DEBUG is enabled: 'currentPhase': 'COMPLETED', 'buildStatus': 'SUCCEEDED', 'sourceVersion': '686fcdc44df8358e3382e80379d7abec66f47e38', 'resolvedSourceVersion': '686fcdc44df8358e3382e80379d7abec66f47e38',

Am I a missing something silly, do you have to create the PR in a certain way?

rehanvdm avatar Nov 05 '21 16:11 rehanvdm

Okay I figured it out, the Codebuild Github source was set to be triggered by PR_MERGE and PUSH. I could see Github send both events at the exact same time. It might be that the logic in the Codebuild receiver side somehow filters (or just wrong logic?) the PR_MERGE event out and then chooses the PUSH instead. After configuring only the PR_MERGE event as a source for the webhook did it start working.

@jlhood might be good to mention something like on the README?

rehanvdm avatar Nov 06 '21 11:11 rehanvdm

Actually, I just spotted that I created the CodeBuild Source Github Event hook to trigger on HEAD_REF instead of BASE_REF, and that is why it never matched and most likely took my other trigger that said PUSH on HEAD_REF.

I think we can close, the AWS CodeXXX suite is not so friendly on documentation.

rehanvdm avatar Nov 08 '21 07:11 rehanvdm

I have exactly the same problem. But I can't figure where exactly you changed the configuration? @rehanvdm did you do this in the web hook on the GitHub side?

bracki avatar Aug 19 '22 11:08 bracki

@bracki No this is on the CodeBuild project, AWS side

rehanvdm avatar Aug 20 '22 08:08 rehanvdm

Figured it out, my case is different. Because we are using batch builds, the actual builds will always have sourceVersion with a resolved version while the triggering build will still have pr/123. To fix this we would need to check if buildBatchArn is set on a build and check the source version of that build instead.

bracki avatar Aug 20 '22 22:08 bracki