job:allow_failure is ignored when some rules exist
Long time no see, thank you for this wonderful tool, once again !
**Minimal .gitlab-ci.yml illustrating the issue**
```yml
---
# BUG: when:manual at job level + rules → ignores allow_failure:false
with-rules-if:
rules:
- if: '$CI_COMMIT_BRANCH == "test"'
script:
- echo "Test"
when: manual
allow_failure: false
# OK: when:manual in rule → respects allow_failure:false
with-rules-when:
rules:
- if: '$CI_COMMIT_BRANCH == "test"'
when: manual
script:
- echo "Test"
allow_failure: false
# OK: no rules → respects allow_failure:false
without-rules:
script:
- echo "Test"
when: manual
allow_failure: false
```
**Expected behavior**
When running `gitlab-ci-local --list-csv`, all three jobs should output `allowFailure;false` because `allow_failure: false` is explicitly set. GitLab CI/CD accepts both syntaxes (`when` at job level or in rules).
**Actual behavior**
```csv
name;allowFailure
with-rules-if;true ← BUG
with-rules-when;false ← OK
without-rules;false ← OK
```
Job `with-rules-if` returns `allowFailure=true` despite explicit `allow_failure: false` at job level.
**Root cause**
When a job has BOTH `rules` and `when: manual` at job level, gitlab-ci-local incorrectly forces `allowFailure = true`, ignoring the explicit `allow_failure: false` configuration.
The issue occurs specifically with this combination:
- Job has `rules` (any rules, even inherited via `extends`)
- Job has `when: manual` at job level (not in the rule)
- Job has explicit `allow_failure: false`
**Workaround**
Move `when: manual` inside the rule definition instead of job level. However, this is a workaround - GitLab's native CI/CD accepts both syntaxes equally.
**Host information**
Windows 11
gitlab-ci-local 4.65.1
**Containerd binary**
N/A - using shell executor (PowerShell)
**Additional context**
This bug impacts CI/CD workflows where manual jobs with rules need to block pipeline progression when not executed.
**Real-world example:**
```yml
.preprod-rules:
rules:
- if: ($CI_COMMIT_TAG || $CI_COMMIT_BRANCH == "tag-test") && $ENVIRONMENT == ""
set-manual-runner:
extends: .preprod-rules
script:
- Set-Service -Name "gitlab-runner" -StartupType Manual
when: manual
allow_failure: false # Should block pipeline but gitlab-ci-local returns true
```
GitLab's native behavior respects explicit `allow_failure: false` on manual jobs with rules, but gitlab-ci-local does not when `when: manual` is at job level.
**Investigation results:**
Tested different combinations to isolate the issue:
- ✅ `when: manual` + `allow_failure: false` (no rules) → returns `false` correctly
- ✅ `extends: .base` + `when: manual` + `allow_failure: false` → returns `false` correctly
- ✅ `environment` + `when: manual` + `allow_failure: false` → returns `false` correctly
- ❌ `rules` + `when: manual` (job level) + `allow_failure: false` → returns `true` (BUG)
- ✅ `rules` with `when: manual` (in rule) + `allow_failure: false` → returns `false` correctly
The bug is specifically triggered by the interaction between `rules` and `when: manual` at job level.
0 条评论