← All guides

Guide · CI/CD

Monitor GitLab CI with a dead man's switch

GitLab's own pipeline emails tell you when a job fails, but not when the pipeline never runs at all: a paused schedule, a runner that quietly disappeared, a broken cron trigger. A check-in catches both, because it alerts on silence, not just on a failure event.

1. Create a check

Create a check in Mortemain, set its schedule to match your pipeline (or its scheduled trigger), and copy the ping URL:

 your ping URL
https://ping.mortemain.com/your-check-uuid

2. Ping on success from after_script

after_script runs after every job in the pipeline, including ones that failed, so guard the call with CI_JOB_STATUS to only ping when things actually went well:

 .gitlab-ci.yml
build:
  stage: build
  script:
    - ./run-build.sh
  after_script:
    - # $CI_JOB_STATUS is set to "success" or "failed" here
    - if [ "$CI_JOB_STATUS" = "success" ]; then
        curl -fsS -m 10 https://ping.mortemain.com/your-check-uuid
      fi

Prefer a dedicated last stage instead? Add a small job that only runs after everything else succeeds:

 .gitlab-ci.yml
stages:
  - build
  - test
  - notify

heartbeat:
  stage: notify
  image: curlimages/curl:latest
  script:
    - curl -fsS -m 10 https://ping.mortemain.com/your-check-uuid

3. Alert immediately on failure

Add a job that only runs when an earlier stage fails, and have it hit the /fail URL. Mortemain alerts right away instead of waiting for the check to go quiet:

 .gitlab-ci.yml
notify_failure:
  stage: notify
  image: curlimages/curl:latest
  script:
    - curl -fsS -m 10 https://ping.mortemain.com/your-check-uuid/fail
  rules:
    - when: on_failure

4. Cover scheduled pipelines

If this pipeline runs on a Scheduled pipeline (CI/CD → Schedules), set your check's period to the same interval. If the schedule gets paused, a runner tag stops matching, or GitLab's scheduler itself stalls, no run means no ping, and Mortemain alerts once the grace window passes. Want to measure how long the pipeline is taking? Hit …/your-check-uuid/start as the first step and Mortemain will track duration between that and the success ping.

Test it

Run the pipeline once (Run pipeline or push a commit) and confirm the check flips to up. Then break a job on purpose and confirm the failure job fires the /fail ping and the alert arrives immediately.