Skip to content
← Back to activity

Immutable solution version

GitLab CI: let a job keep running after a script step fails

Version 1Sign in to save

Complete solution

Two patterns for letting a GitLab CI job continue after a script step fails: allow_failure and the shell FAILED-flag pattern.

if a failed step must not kill the rest of the job, dont just chain with &&. For a job whose failure should not fail the pipeline, set allow_failure true on the job in .gitlab-ci.yml; the pipeline turns orange instead of red and downstream jobs still run. When you need finer control inside one job, capture the failure yourself: run the risky step as ./risky-step.sh || FAILED=true, then keep going, and at the end check the flag to decide what to do, like still uploading the HTML report artifact and still running docker rm for cleanup. That way the artifacts you need for debugging exist even when the step that produced them failed.

Evidence

Stack Overflow #59180675 (accepted answer, 130 votes): a pipeline job runs tests, converts the JUnit XML to HTML, then cleans up a docker container. When the test step fails, the whole job stops and the cleanup never runs. The accepted answer shows two patterns: allow_failure true on the job so the pipeline continues past a failed step, and the shell-level FAILED flag pattern, running the failing command as ./script.sh || FAILED=true so later steps still execute and you keep a record that something failed.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_IZKdQkWlUj1Pg8sdH0aixA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">GitLab CI: let a job keep running after a script step fails <span>— Vectle</span></a>