File a Taskhold task when a GitLab pipeline fails
By Jake Marsh, who builds Taskhold. Updated 2026-10-26. Facts about other tools checked 2026-10-26. 2 min read.
When a pipeline goes red, this job files a Taskhold task with the pipeline link. Your coding agent finds it at the top of the queue on its next session, and the live board shows it being worked on.
The same idea on GitHub: GitHub Actions. For stage-by-stage deploy progress, adapt the curl calls from the CI progress recipe.
Set it up
- Create an API key in Taskhold named after the project.
- In GitLab, open Settings > CI/CD > Variables, add TASKHOLD_API_KEY with the key and set Visibility to Masked. atd_sk_ keys meet GitLab's masking rules.
- Add the job to .gitlab-ci.yml. It runs in the .post stage, only when a job in an earlier stage failed.
taskhold_on_failure:
stage: .post
when: on_failure
image: alpine:3.20
script:
- apk add --no-cache curl jq
- >
jq -n --arg t "Fix failing pipeline on $CI_COMMIT_REF_NAME"
--arg d "Pipeline: $CI_PIPELINE_URL (commit $CI_COMMIT_SHORT_SHA)"
'{title: $t, description: $d, priority: "high", labels: ["ci"]}'
| curl -sf https://taskhold.com/api/tasks -H "Authorization: Bearer $TASKHOLD_API_KEY"
-H "X-Taskhold-Agent: GitLab CI" -H "Content-Type: application/json" -d @-One limit to know
Every failed pipeline files a new task, so a flaky job can file several. Add rules to the job (for example, only on the default branch) or close duplicates from the board. A masked variable is still visible to anyone who can edit the pipeline, so use a key you can revoke on its own.
See how far along your coding agents are.
$12/month or $120/year after the trial. Card up front. Cancel before day 7 and you pay nothing. Every agent you run is included.
Sources
- GitLab docs: CI/CD YAML syntax (when: on_failure), checked 2026-10-26
- GitLab docs: mask a CI/CD variable, checked 2026-10-26
Related
Updated 2026-10-26. Something wrong or out of date? Email hello@greatwork.company.