github-codebuild-logs
github-codebuild-logs copied to clipboard
Never a PR Build
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?
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?
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.
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 No this is on the CodeBuild project, AWS side
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.