From 584c1797cf6930d1f4d9d8f80cc463b8874329a1 Mon Sep 17 00:00:00 2001 From: Garrison Davis Date: Tue, 16 Aug 2022 13:00:37 -0600 Subject: [PATCH] Use CI_COMMIT_REF_SLUG to tag Docker images (#2191) We're using this because it's a builtin env variable that comes with GitLab, and it fixes one of the annoying things about Docker tags (e.g., you can't use all of the allowed characters in Git branches). One issue that I've seen a few times, is branches with either capital letters (which was recently broken), or using the '/' character. This PR makes it so we always use the CI_COMMIT_REF_SLUG when making or referencing images so that it is always consistent. Note: this might make it slightly harder to intuit what the correct Docker image to make (if you wanted to use the one built by CI rather than locally). This trade off doesn't seem too hard to overcome. --- .gitlab/.gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index 3a716508b..74701278a 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -139,7 +139,7 @@ build amd container fb: before_script: - echo "${DOCKER_DEPLOY_TOKEN}" | docker login -u ${DOCKER_DEPLOY_USER} --password-stdin ${CI_REGISTRY} script: - - tag=${CI_REGISTRY_IMAGE}/featurebase:linux-amd64-${CI_COMMIT_REF_NAME} + - tag=${CI_REGISTRY_IMAGE}/featurebase:linux-amd64-${CI_COMMIT_REF_SLUG} - docker build --build-arg GO_VERSION=$GOVERSION --build-arg ARCH=amd64 -t $tag -f .gitlab/Dockerfile . - docker push $tag - echo Created docker featurebase image with tag "$tag" @@ -252,7 +252,7 @@ run go tests idk race: - command -v certstrap >/dev/null || go install github.com/square/certstrap@latest - echo $PROJECT - echo $DOCKER_PASSWORD | docker login registry.gitlab.com --username "$USERNAME" --password-stdin - - BRANCH_NAME=${CI_COMMIT_BRANCH} make test-all-race + - BRANCH_NAME=${CI_COMMIT_REF_SLUG} make test-all-race after_script: - make save-pilosa-logs - make shutdown @@ -283,7 +283,7 @@ run go tests idk shard transactional: - command -v certstrap >/dev/null || go install github.com/square/certstrap@latest - echo $PROJECT - echo $DOCKER_PASSWORD | docker login registry.gitlab.com --username "$USERNAME" --password-stdin - - BRANCH_NAME=${CI_COMMIT_BRANCH} make test-all + - BRANCH_NAME=${CI_COMMIT_REF_SLUG} make test-all after_script: - make save-pilosa-logs - make shutdown @@ -311,7 +311,7 @@ run go tests idk 533: - cd ./idk/ - command -v certstrap >/dev/null || go install github.com/square/certstrap@latest - echo $DOCKER_PASSWORD | docker login registry.gitlab.com --username "$USERNAME" --password-stdin - - CONFLUENT_VERSION=5.3.3 BRANCH_NAME=${CI_COMMIT_BRANCH} make test-all + - CONFLUENT_VERSION=5.3.3 BRANCH_NAME=${CI_COMMIT_REF_SLUG} make test-all after_script: - make save-pilosa-logs - make shutdown @@ -340,7 +340,7 @@ run go tests idk sasl: - cd ./idk/ - command -v certstrap >/dev/null || go install github.com/square/certstrap@latest - echo $DOCKER_PASSWORD | docker login registry.gitlab.com --username "$USERNAME" --password-stdin - - BRANCH_NAME=${CI_COMMIT_BRANCH} make test-all-kafka-sasl + - BRANCH_NAME=${CI_COMMIT_REF_SLUG} make test-all-kafka-sasl after_script: - make save-pilosa-logs - make shutdown @@ -578,7 +578,7 @@ build arm container fb: before_script: - echo "${DOCKER_DEPLOY_TOKEN}" | docker login -u ${DOCKER_DEPLOY_USER} --password-stdin ${CI_REGISTRY} script: - - tag=${CI_REGISTRY_IMAGE}/featurebase:linux-arm64-${CI_COMMIT_REF_NAME} + - tag=${CI_REGISTRY_IMAGE}/featurebase:linux-arm64-${CI_COMMIT_REF_SLUG} - docker build --build-arg GO_VERSION=$GOVERSION --build-arg ARCH=arm64 -t $tag -f .gitlab/Dockerfile . - docker push $tag - echo Created docker featurebase image with tag "$tag"