Answer a question

In order to add pull request checks from external tools (e.g. SonarCloud) during a CodeBuild job, I need to provide PR details - e.g. the numeric PR key, the base branch, and the compare branch.

I know these are present in the GitHub PR web hook, but I can't access that within CodeBuild.

However CodeBuild is able to post back its own build check, i.e. block the merge if the build fails, so I know that these details must available.

How can I access them from within a CodeBuild 'build context'?

Answers

Kirk,

We added a few more preconfigured environment variables for webhook builds in AWS CodeBuild.

CODEBUILD_WEBHOOK_EVENT: The webhook event that triggered the current build.

CODEBUILD_WEBHOOK_HEAD_REF: The head reference name of the webhook event that triggered the build. It could be a branch reference or a tag reference.

CODEBUILD_WEBHOOK_BASE_REF: The base reference name of the webhook event that triggered the build. It is the branch reference for pull requests.

CODEBUILD_WEBHOOK_ACTOR_ACCOUNT_ID: The account id of the user who triggered the webhook event

These are the ones in addition to what was already documented in https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html.

Let us know if this doesn't suffice.

Logo

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!

更多推荐