Skip to content

Allow optional artefact pass between multi project pipelines

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem to solve

Allow downstream pipelines in multi-project pipelines to define that the upstream job might send an artifact when triggering the downstream pipeline, but it would also be optional in the same way you can define that the specific job can be needed if present (optional) in regular pipelines.

Proposal

Expand the current needs property when defining a job, in case you want also put a dependency on the artifact of the required job, but only if it created it. In case it didn't, nothing happens meaning an artifact would not be downloaded (since it wasn't created), and the downstream pipeline would continue in its order. It can use the existing optional keyword which is used to define that the required job can be optional (example A), or expand the artifacts keyword in the needs section (example B) so it does not interfere with the existing optional keyword meaning.

Example A

jobC:
  needs:
    - project: group/projectA
      job: jobA
      ref: master
      artifacts: true
      optional: true

Example B

jobC:
  needs: 
    - project: group/projectA
      job: jobA
      ref: master
      artifacts:
        enabled: true
        optional: true
    - project: group/projectB
      job: jobB
      ref: master
      artifacts:
        enabled: true
        optional: true

Additional explanation

Imagine you have 3 projects (A, B, and C) in the same group. At the moment you can pull off triggering pipeline C from project A, while passing it an artifact. Now imagine you want to expand that so that you want to trigger the same pipeline C but this time from project B, while also passing an artifact to it, but it does not have to happen simultaneously. So the case is that you want to trigger the pipeline from project C with either project A or project B while passing it an artifact. It requires you to write 2 items in the needs array, but you are not allowed to put optional inside, and if you put artifacts: true in both of them the job will fail since it will require a trigger from both pipelines. Current workaround would be to have a clone job in pipeline C for each project that would want to trigger pipeline C.

Edited by 🤖 GitLab Bot 🤖