1
create_docker_build_env:
    ...
    rules:
        - changes:
            - Dockerfile
          when: always
        - if: $CI_REGISTRY_IMAGE/build_env:latest ?does not exist?
          when: always
        - when: never

I have a CI task that creates a docker container that is used for CI builds. There is a rule that rebuilds the container each time the dockerfile changes. Unfortunately, it doesn't work in case of forks: whoever will fork the repo will end up with the failed build, since they don't have the needed containers. Is there a way to make a condition based on existence of the docker container?

Morse
  • 1,330
  • 2
  • 17
  • 27
  • I dont think that this is possible. But you could run a script that checks the existence of your docker image. Then you could run or don't run a downstream job. https://stackoverflow.com/questions/66016408/gitlab-ci-run-job-only-if-artifact-exists/68269921#68269921 – Jakob Liskow Mar 13 '23 at 22:23

0 Answers0