Semantics of using "job.needs" and "job.if" together #25286
-
The documentation at https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idneeds states:
Now suppose I have a job configured as follows:
Will job2 always run regardless of the outcome of job1? Will it at least wait until job1 finishes? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @hiranya911 , Job2 will be executed until job1 finished. As doc mentioned, if job1 failed, job2 will be skipped. The exception is, if you set ‘if: always()’ in job2, job2 will be executed even job1 failed. Please refer to the official doc for more details.
|
Beta Was this translation helpful? Give feedback.
-
Thanks @weide-zhou It’s great to know that
Here job2 never runs (even if the client_payload.job2 is set to true), since the job1 is guaranteed to fail. This is exactly the semantics I needed for my workflow. |
Beta Was this translation helpful? Give feedback.
-
you have to use always() it is a special flag |
Beta Was this translation helpful? Give feedback.
Hi @hiranya911 ,
Job2 will be executed until job1 finished. As doc mentioned, if job1 failed, job2 will be skipped.
The exception is, if you set ‘if: always()’ in job2, job2 will be executed even job1 failed. Please refer to the official doc for more details.