Repository navigation
Open
Labels
bugSomething isn't working
Description
Describe the bug
One or more jobs are skipped in a workflow when run after successfully running a job matching following conditions:
- Job has NEEDS dependency on one or more preceding jobs. (i.e. needs: [job1, job2])
- Job has if condition specifying behavior when NEEDS jobs are skipped. (i.e. if: always() && needs.job1.result == 'skipped')
- Preceding job is skipped (i.e. job1)
To Reproduce
Create a workflow as follows:
name: Skipped Job Test
on:
workflow_dispatch:
jobs:
Skipped-Job:
name: skipped job
runs-on: [self-hosted]
if: 1 != 1
steps:
- name: write to console 1
run: Write-Host "I should be skipped"
Needs-Job:
name: needs conditional job
needs: Skipped-Job
if: always() && needs.Skipped-Job.result != 'failed' # this should run eventhough needs the skipped-job
runs-on: [self-hosted]
steps:
- name: write to console 2
run: Write-Host "Needs-Job completed"
Next:
name: Next job
needs: Needs-Job
# if: always() && needs.Needs-Job.result == 'success' # uncommenting this condition causes the job to not be skipped
runs-on: [self-hosted]
steps:
- name: write to console 3
run: Write-Host "I should print whenever Needs-Job succeeds"
Expected behavior
I'd expect the job "Next" to run, because the preceding job " Needs-Job" is completed successfully and is the only condition for this job to run (it needs Needs-Job), it is however skipped.
uncommenting the 3rd line in that job is a fix, but this feels hacky and shouldn't be needed.
Runner Version and Platform
Current runner version: '2.298.2'
Running on: Windows Server 2022 Standard
Version 21H2
OS build 20348.1006
Reacted by Will Bamford, Jack Flukinger, Tyler Chong, Mauro Ezequiel Moltrasio, Marco Henriques, edgarmartinez-43, Daniel Zhang, Yonatan Wilkof, Serhii Povísenko, William Chhim and 74 more
Reacted by Dmytro Kashcheiev, zhongfly, Robert McNamara, Bengt Brodersen, Marcel Richter, WhiteRabbit, Jbhadviya, Balassa Ádám and Jason Nader
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
GennaroGreg commentedon Nov 2, 2022
I believe the status is the wrong word - try ‘failure’ instead of ‘failed’.
niekvanderreest commentedon Nov 22, 2022
Hi @GennaroGreg,
Thanks for the reply, the status 'failed' might indeed be the wrong word, however it shouldn't matter for job "Needs-Job" as the check is if it's not equal to, and since "Skipped-Job" is always skipped the status will always be 'skipped' (right?)
I've tested just to be sure:

DameonSmith commentedon Dec 8, 2022
I'm having a similar problem. Where a job earlier in the chain is skipped causes all down stream jobs to be skipped even if they don't explicitly state that they need that job to continue.
Following pseudo code demonstrates what I'm seeing.
mulhotavares commentedon Jan 13, 2023
@DameonSmith IIRC you'd need to add
if: always() && needs.do-task-a.result == successin this case. Once a job in the workflow is failed or skipped, you need to overwrite the conditional for all subsequent jobs...niekvanderreest commentedon Jan 17, 2023
Hi @mulhotavares, thanks for the comment, I do know this works but I consider it a workaround. I could be wrong however and this could be intended behavior, do you perhaps have a link to Github documentation that explains this as intended behavior?
It feels like a bug that the run condition on job A would impact job C that has no condition on the skipped job (only on job B which is run and successful)
ci: make sure deploy is working when validate-tests is skipped
mulhotavares commentedon Jan 17, 2023
Hi @niekvanderreest.
In terms of the documentation, I haven't found that mentioned directly, but the docs do state:
And
(both quotes from this: https://docs.github.com/en/actions/learn-github-actions/expressions#job-status-check-functions)
So it is respecting both of those statementes, but I agree this looks awkward. Anyways, I was just trying to help, especially as others could find this in Google like I did. 😄
ywilkof commentedon Jan 20, 2023
Experienced this as well. Unless explicitly documented, this feels like a bug. Current behavior is unintuitive as well as cumbersome to develop, since one has to push the
ifclause to all descendent jobs just because of one skipped ancestor.kgreav commentedon Jan 23, 2023
This is really weird behaviour. As noted here this definitely seems to be a bug (why are we all just running into this now? did everyone suddenly decide to use job ifs?).
A job being skipped seems to be treated as failed, so
success()doesn't work for follow on jobs. As documented in the discussion, you should instead use! failure()which works a treat, but you then have to propagate it to all descendant jobs even if they don't directly depend on the skipped job, which is very confusing.You should fix
success()to not include skipped jobs, as skipped really should mean "this wasn't needed", not "this failed". And needs checks should only occur on the explicitly listed jobs, not ancestors of those jobs.jjoseph456 commentedon Jan 23, 2023
I have a workflow skips or cancels as soon as it is executed
niekvanderreest commentedon Jan 23, 2023
@jjoseph456 , I think your workflow has an execution order issue, the first job has a needs specifying the second job. Switching position of first and second job should fix this.
I'm no expert at this field, most of the workflow I worked on have a strict order of execution.
jjoseph456 commentedon Jan 23, 2023
@niekvanderreest thanks will try that
Add possible conditional fixes
povisenko commentedon Jan 27, 2023
having the same issue, once always() used in job1, the next job that needs it will not be executed even if the job1 succeeds
39 remaining items
fix: enforce release-merge-guard on workflow_dispatch and fix publish…
ci(ci): fix skipped jobs when quality gate bypassed W-21933934
[W-21933934] ci(ci): fix skipped jobs when quality gate bypassed (#306)
fix: enforce release-merge-guard on workflow_dispatch and fix publish…
fix(ci): resolve sign-and-verify failure and remove redundant CI jobs
[ci] W: Run Nightly Release on Transient Errors
[ci] F: Fix nightly release transitive skip
fix(ci): un-poison and harden the deploy-cloudflare chain (refs #283)
feat: Epic #279 (#286)
fix(release): make staging Web SPA deploy actually run (fixes false "…
Cherry-picks for release/v0.10.7 (#37359)
Release v0.10.7 (#37447)
fix(publish): publish-ecosystem was unconditionally skipped by implic…
fix(release): unskip the staging deploy on ordinary pushes (#14)
Speed up CI/CD: buildhash skip, digest-pinned bases, layer ordering