Describe your question in as much detail as possible:
I think I have some misunderstanding of “needs:” keyword in Gitlab CI.
Here is a part of my gitlab-ci.yml:
stages: - build_latest - build_tagged latest_build: stage: build_latest rules: - if: '$CI_COMMIT_BRANCH == "master"' when: on_success script: - | docker build --pull -t "$CI_REGISTRY_IMAGE:latest" . docker push "$CI_REGISTRY_IMAGE:latest" tagged_build: stage: build_tagged needs: - latest_build rules: - if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/' script: - | docker pull "$CI_REGISTRY_IMAGE:latest" docker tag "$CI_REGISTRY_IMAGE:latest" "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
The goal is to build image with “latest” tag, then, if this stage succeeded and the latest commit is associated with git tag, to tag docker image accordingly. However, I’m getting a YAML error: “tagged_build: needs ‘latest_build’”
And I don’t understand why this happens, because “build_latest” succeeds and “build_tagged” gets cancelled immediately on push:
Most likely my error is explained at https://docs.gitlab.com/ee/ci/yaml/#requirements-and-limitations: " If
needs: is set to point to a job that is not instantiated because of
only/except rules or otherwise does not exist, the pipeline is not created and a YAML error is shown.", however, “build_latest” job does run and even finish successfully.
I’m running a self-hosted “free” Gitlab instance, version 13.5.3