Monitor scheduled GitLab CI pipelines with HookPulse
after_script reports each scheduled run to HookPulse, success or failure, from the job status.
Updated
1Create the monitor
Add a routine named gitlab-backup and set how often the job runs. Its page shows the check-in URL: use it in place of https://hookpulse.net/in/YOUR_ID.
2Save the check-in URL as a variable
In Settings, CI/CD, Variables, add HOOKPULSE_URL with the check-in URL, masked.
3Add the check-in to the job
after_script also runs when the script fails, and CI_JOB_STATUS tells which one happened.
backup:
image: alpine:3.20
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
script:
- ./backup.sh
after_script:
- apk add --no-cache curl
- |
if [ "$CI_JOB_STATUS" = "success" ]; then curl -fsS -m 10 --retry 3 "$HOOKPULSE_URL"
else curl -fsS -m 10 --retry 3 "$HOOKPULSE_URL/fail"; fi4Run it once
Run the pipeline schedule once from Build, Pipeline schedules. The routine shows the first check-in. From then on, a missed or failed run sends the alert.