From 4495abcd8c7ce7fead1fc1b6f5add14ded3ccef5 Mon Sep 17 00:00:00 2001 From: Tobias Hernstig Date: Wed, 25 Jul 2018 06:49:56 +0000 Subject: [PATCH] Update doc/ci/docker/using_docker_build.md --- doc/ci/docker/using_docker_build.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/ci/docker/using_docker_build.md b/doc/ci/docker/using_docker_build.md index fbac37e688e..63338ff632c 100644 --- a/doc/ci/docker/using_docker_build.md +++ b/doc/ci/docker/using_docker_build.md @@ -427,7 +427,7 @@ services: variables: DOCKER_HOST: tcp://docker:2375 DOCKER_DRIVER: overlay2 - IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG before_script: - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY @@ -440,8 +440,10 @@ build: ``` Here, `$CI_REGISTRY_IMAGE` would be resolved to the address of the registry tied -to this project, and `$CI_COMMIT_REF_NAME` would be resolved to the branch or -tag name for this particular job. We also declare our own variable, `$IMAGE_TAG`, +to this project. Since `$CI_COMMIT_REF_NAME` resolves to the branch or tag name, +and your branch-name can contain forward slashes (e.g., feature/my-feature), it is +safer to use `$CI_COMMIT_REF_SLUG` as the image tag. This is due to that image tags +cannot contain forward slashes. We also declare our own variable, `$IMAGE_TAG`, combining the two to save us some typing in the `script` section. Here's a more elaborate example that splits up the tasks into 4 pipeline stages, @@ -464,7 +466,7 @@ stages: variables: DOCKER_HOST: tcp://docker:2375 DOCKER_DRIVER: overlay2 - CONTAINER_TEST_IMAGE: registry.example.com/my-group/my-project/my-image:$CI_COMMIT_REF_NAME + CONTAINER_TEST_IMAGE: registry.example.com/my-group/my-project/my-image:$CI_COMMIT_REF_SLUG CONTAINER_RELEASE_IMAGE: registry.example.com/my-group/my-project/my-image:latest before_script: -- GitLab