Gitlab-ci : how to run a job when one of numerous other jobs or done

3.1k views Asked by At

I need to set a job that starts running after one of several other jobs are done , that are all in the same stage.

I ve tried to use the keyword "needs" , but i didn't recognize how to tell it to consider the case of "if only one among all job is done"

What i'm looking for , is some way to get it :

if : JOB_A is done OR JOB_BA is done

then : Run JOB_C

JOB_A
  stage: mystage
...

JOB_B
  stage: mystage
...

JOB_C:
  stage: mystage
  variables:
    PLAYBOOK_NAME: myplaybook.yml
    INVENTORY_NAME: myInventory.yml
  needs: [JOB_A or JOB_B]  # THIS is a wrong way to set it i think
  when: manual

Suggestions ??

1

There are 1 answers

0
Corentin Jacquet On

In the use case you describe, the needed jobs are manually run and so are only added to the pipeline when you run them, so you should be able to use needs with optional set to true as described in the doc here needing all the jobs this way could fit your use case.

I have to say I'm not convinced by the need of automating jobs after with manual jobs. It seems to me the several manual jobs could be refactored in one with the use of environment variables, but we don't have enough info to help you on this design.