Answer the question
In order to leave comments, you need to log in
Why doesn't Gitlab push variables to all branches?
I created and configured gitlab ci, added variables to the gitlab interface. I'm trying
to make different build settings for different branches.
However, I ran into the fact that when the build occurs on all branches except master, the build does not receive environment variables.
image: docker:stable
services:
- docker:dind
stages:
- test
- package
variables:
DOCKER_HOST: tcp://dockerhost
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "/certificates"
before_script:
- mkdir -p $DOCKER_CERT_PATH
- echo "$TLSCACERT" > $DOCKER_CERT_PATH/ca.pem
- echo "$TLSCERT" > $DOCKER_CERT_PATH/cert.pem
- echo "$TLSKEY" > $DOCKER_CERT_PATH/key.pem
- echo $HUB_REGISTRY_PASSWORD
- echo $TLSCACERT
- cat $DOCKER_CERT_PATH/ca.pem
- docker login -u derbenev -p $HUB_REGISTRY_PASSWORD $CI_REGISTRY
test:
stage: test
only:
- develop
- master
- prod
tags:
- docker
script:
- pwd
- sh test.sh
develop:
stage: package
only:
- develop
tags:
- docker
script:
- build.sh
$ cat $DOCKER_CERT_PATH/ca.pem
-----BEGIN CERTIFICATE----- **** -----END CERTIFICATE-----
$ docker login -u derbenev -p $HUB_REGISTRY_PASSWORD $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ echo $HUB_REGISTRY_PASSWORD
***
$ echo $TLSCACERT
-----BEGIN CERTIFICATE----- *** --END CERTIFICATE-----
$ echo $HUB_REGISTRY_PASSWORD
$ echo $TLSCACERT
$ cat $DOCKER_CERT_PATH/ca.pem
$ docker login $CI_REGISTRY
failed to append certificates from PEM file: "/certificates/ca.pem"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question