I am trying to figure out, why when my CI builds are running, the secure variables I setup on a project are not available on the CI runner.
I am managing all of my docker images using tutum.co. On my gitlab server, I have gitlab, and the runner operational and they work.
gitlab image: https://hub.docker.com/r/sameersbn/gitlab/
runner image: https://hub.docker.com/r/rayrutjes/simple-gitlab-runner/
With that runner image, it shares the docker.sock from the host which is where the main docker daemon is running. This works fine for all my builds. So when a build runs, it builds the image on the main gitlab host in a new docker container. Not in the CI container. Everything works fine except when using the project specific secure variables.
For example, if I set the secure variable DOCKER_USER
on the project, when the CI runner runs, and I echo out the command to log into the docker hub (to bush built images) it just spits out the command literally with the name of the env var. Which makes the docker login
command fail.
here is an example of my .gitlab-ci.yml
file:
before_script:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p '$DOCKER_PASS'
stages:
- build
- pushdocker
build:
stage: build
script:
- docker build -t username/image .
only:
- master
tags:
- docker
pushdocker:
stage: pushdocker
script:
- docker push username/image
tags:
- docker
And when the build fails, this is the output:
gitlab-ci-multi-runner 0.5.5-1-g69bc934 (69bc934)
Using Shell executor...
stdin: is not a tty
Running on gitlab-simple-runner-1...
$ docker login -e ${DOCKER_EMAIL} -u ${DOCKER_USER} -p '${DOCKER_PASS}'
Username: EOF
ERROR: Build failed with: exit status 1
Testing that command (with the credentials filled in) on the server running docker, as well as the gitlab/ci images, all work without giving the EOF error.
Maybe I am doing this incorrectly. I am just trying to figure out what is going on wrong.
As a note, when the images build from the build
step, they are run on the host machine and not in a container. So maybe gitlab isnt able to set the variables on the host machine? Or those variables are getting run on the CI image and then its building on the host?