Life is great as I have 2 Gitlab CI projects that should both push docker images to the same directory and both have the some configuration but one is working, one is not…
Working:
push_gcp:
only:
- master
image: docker:dind
before_script:
- docker login registry.gitlab.com -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}
- echo $GCLOUD_SERVICE_ACCOUNT_BASE64 > gcloud-service-key.txt
- cat gcloud-service-key.txt | docker login -u _json_key_base64 --password-stdin https://europe-west4-docker.pkg.dev
script:
- ...
after_script:
- docker logout ${CI_REGISTRY}
- docker logout https://europe-west4-docker.pkg.dev
stage: push
allow_failure: false
tags:
- docker
Failing:
push_gcp:
only:
- master
image: docker:dind
before_script:
- docker login registry.gitlab.com -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}
- echo $GCLOUD_SERVICE_ACCOUNT_BASE64 > gcloud-service-key.txt
- cat gcloud-service-key.txt | docker login -u _json_key_base64 --password-stdin https://europe-west4-docker.pkg.dev
script:
- ...
after_script:
- docker logout ${CI_REGISTRY}
- docker logout https://europe-west4-docker.pkg.dev
stage: push_image
allow_failure: false
tags:
- docker
Any ideas? I’m going mental here..
2
Answers
A bit late but the solution was to disable protected variables in Gitlab CI/CD settings.
Try this:
basically after
--password-stdin
, use<
.