Convert these Codebuild specific vars into more standard names and pass in as build args to the docker image
| Purpose |
CodeBuild Var |
Neutral / “Industry-standard” Name |
Why |
| Source ref (branch or tag) |
CODEBUILD_WEBHOOK_HEAD_REF |
CI_COMMIT_REF |
GitLab CI, Drone, Buildkite use this. GitHub Actions has GITHUB_REF which is similar. |
| Commit SHA |
CODEBUILD_RESOLVED_SOURCE_VERSION |
CI_COMMIT_SHA |
Widely adopted (CI_COMMIT_SHA in GitLab, GITHUB_SHA in Actions, DRONE_COMMIT_SHA, etc.). |
| Build start time |
CODEBUILD_START_TIME |
CI_BUILD_STARTED_AT |
Less standardized, but GitLab/Drone use CI_PIPELINE_CREATED_AT or DRONE_BUILD_STARTED. The CI_BUILD_* prefix keeps it consistent. |
| Repository URL |
CODEBUILD_SOURCE_REPO_URL |
CI_REPOSITORY_URL |
Common in GitLab and others (CI_REPOSITORY_URL gives the clone URL). |
Note that CODEBUILD_WEBHOOK_HEAD_REF is only set on builds triggered by a webhook. For a manual build, we should use the the branch it pulled from. It may make more sense to use CODEBUILD_SOURCE_VERSION.
Docs: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
Convert these Codebuild specific vars into more standard names and pass in as build args to the docker image
Note that
CODEBUILD_WEBHOOK_HEAD_REFis only set on builds triggered by a webhook. For a manual build, we should use the the branch it pulled from. It may make more sense to useCODEBUILD_SOURCE_VERSION.Docs: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html