The documentation at https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idneeds states:
If a job fails, all jobs that need it are skipped unless the jobs use a conditional statement
that causes the job to continue.
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?
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.
It’s great to know that
always() works in the context of chained jobs too. I also tried the following, as a further experiment, and thought I’d share my results:
- run: |
echo Job 1
- run: echo Job 2
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.
you have to use always() it is a special flag