Allow predefined variables for keyword 'image:' in .gitlab-ci.yml

Description

We would like to implement the following workflow:

  • Build a docker image and push it to the registry in stage A
  • Use the just built image as image: in stage B to run test

While this is possible right now, it becomes problematic if multiple builds are run parallel: You can not be sure if the images pushed in stage A to the registry is the one used by the ci runner in stage B.

Proposal

It would be great if [predefined variables][1] would be allowed within image:, so something like the following would work:

build:image:
  stage: build
  script:
    - docker build -t registry.example.com:443/mygroup/myproject:${CI_PIPELINE_ID} ./myimage
    - docker push registry.example.com:443/mygroup/myproject:${CI_PIPELINE_ID}

test:app:phpunit:
  stage: test
  image: registry.example.com:443/mygroup/myproject:"${CI_PIPELINE_ID}"
  script:
    - phpunit

Note that [predefined variables][1] are already allowed in e.g. [cache: key:][2]

Right now trying this leads to an output like this:

Running with gitlab-ci-multi-runner 1.4.1 (fae8f18)

ERROR: The registry.example.com:443/mygroup/myproject:"${CI_PIPELINE_ID}" is not present on list of allowed images
- registry.example.com/*/*
- registry.example.com/*/*:*

Please check runner's configuration: http://doc.gitlab.com/ci/docker/using_docker_images.html#overwrite-image-and-services
ERROR: Build failed (system failure): invalid image

Links / references

  • [predefined variables][1] [1]: http://docs.gitlab.com/ce/ci/variables/README.html#predefined-variables-environment-variables
  • [cache: key:][2] [2]: http://docs.gitlab.com/ce/ci/yaml/README.html#cachekey

~"feature proposal"

Assignee Loading
Time tracking Loading