Use default branch image if previous stage didn't run
As it can be seen in https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/macstadium/orka/-/pipelines/191323284, a change in group_vars/all/package_managers.yml
triggered the Lint
job and immediately the Toolchain image
job.
Proposal
When there are no changes to previous images, the job should just use the unmodified base image. In the case described above, it should try to use gitlab-base-10.15-beta.img
instead of mr-29-gitlab-base.img
. This will fix the pipeline, in addition to reducing resource usage and time to completion.
To achieve this, each image generation job should output an env artifact containing the name of the generated image, to be used by the later stage. If the artifact is not available, that means that preceding jobs did not run, and therefore we can use the respective image from the default (master
) branch. In the case that we're not targeting the default branch, we'll need to rebuild all preceding base images, since we can't easily tell the name of the VM images we should use as the base (or whether they are even available).