2

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 ??

firasKoubaa
  • 6,439
  • 25
  • 79
  • 148
  • Could you explain the use case? We might find a better fitting solution for your problem. – J Fabian Meier Apr 13 '22 at 11:14
  • @JFabianMeier , i ve several job , each job is used to deploy on a specifc platform , when the deployement ends , i need to run a specific job that save some infos about the deployment already done – firasKoubaa Apr 13 '22 at 11:53
  • But if one deployment has happened and the other is still running, you want to ignore the result of the other deployment. It seems a bit strange that the first successful deployment will be analysed and the others do not matter. – J Fabian Meier Apr 13 '22 at 12:00
  • all my deployement are Manual , – firasKoubaa Apr 13 '22 at 12:26
  • So you actually just execute one of many possible deployments? – J Fabian Meier Apr 13 '22 at 15:48
  • There is a similar post here, using a downstream pipeline could be a workaround for you? https://stackoverflow.com/questions/72619985/start-next-job-when-one-of-the-previous-manual-jobs-are-a-success/72623374#72623374 – Oceania Water Jun 15 '22 at 07:28

1 Answers1

1

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.