get GitHub git branch for AWS CodeBuild

前端 未结 5 1770
鱼传尺愫
鱼传尺愫 2021-02-07 08:15

I\'m setup AWS CodeBuild to build automatically from GitHub. Other CI services provide an environment variable for the branch, but I can\'t find one for AWS CodeBuild. There is

5条回答
  •  一向
    一向 (楼主)
    2021-02-07 08:54

    It's now possible to obtain this information directly from CodeBuild environmental variables:

    • CODEBUILD_WEBHOOK_BASE_REF: The base reference name of the webhook event that triggers the current build. For a pull request, this is the branch reference.
    • CODEBUILD_WEBHOOK_HEAD_REF: The head reference name of the webhook event that triggers the current build. It can be a branch reference or a tag reference.
    • CODEBUILD_WEBHOOK_TRIGGER: Shows the webhook event that triggered the build. This variable is available only for builds triggered by a webhook. The value is parsed from the payload sent to CodeBuild by Github, Github Enterprise, or Bitbucket. The value's format depends on what type of event triggered the build.
      • For builds triggered by a pull request, it is pr/pull-request-number.
      • For builds triggered by creating a new branch or pushing a commit to a branch, it is branch/branch-name.
      • For builds triggered by a pushing a tag to a repository, it is tag/tag-name.

提交回复
热议问题