I am new to GitLab Auto DevOps.
I encountered some environment variables which are "CI_APPLICATION_TAG"、"CI_APPLICATION_REPOSITORY"、"CI_COMMIT_REF_SLUG".
I can't find where their definitions are. Is there anyone can help me?
I am new to GitLab Auto DevOps.
I encountered some environment variables which are "CI_APPLICATION_TAG"、"CI_APPLICATION_REPOSITORY"、"CI_COMMIT_REF_SLUG".
I can't find where their definitions are. Is there anyone can help me?
You can see them in action in gitlab-org/gitlab-ci-yml issue 50
The Docker image naming strategy in Auto DevOps is defined via the
CI_APPLICATION_REPOSITORYandCI_APPLICATION_TAGvariables near the start of the auto_devops before_script.
The format differs from the way I name and tag images, but the inline export statements make it difficult to customize since the script itself has to be modified.export CI_APPLICATION_REPOSITORY=$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG export CI_APPLICATION_TAG=$CI_COMMIT_SHA
Also, gitlab-org/gitlab-ce issue 53129
For building Docker images in a project, GitLab CI provides the predefined variable
CI_REGISTRY_IMAGEthat returns the base image name for images stored the Container Registry tied to the project.This can be be used in conjunction with
CI_COMMIT_REF_NAMEorCI_COMMIT_REF_SLUGfor the image tag.The
Docker.gitlab-ci.ymltemplate demonstrates this in its build job script.- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"GitLab Auto DevOps declares two local variables in its before_script for the image name and tag.
export CI_APPLICATION_REPOSITORY=$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG export CI_APPLICATION_TAG=$CI_COMMIT_SHA
With:
CI_APPLICATION_REPOSITORYis used to define the image name, andCI_APPLICATION_TAGfor the image tag
Snippet from https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml
if [[ -z "$CI_COMMIT_TAG" ]]; then
export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG}
export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA}
else
export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE}
export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_TAG}
fi