Skip to content

Pass common CI vars into builder as build args #13

@ipmb

Description

@ipmb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions