GitLab CI/CD
Add one job to .gitlab-ci.yml and a failed pipeline arrives on your devices
with a button that opens it in GitLab.
This uses an API Source, with curl and jq.
Set it up
Section titled “Set it up”-
In the Pocketbell app, create a Source named GitLab, choose API, and copy its key.
-
In the project, open Settings → CI/CD → Variables, click Add variable, set the key to
POCKETBELL_KEYand the value to your key, and set Visibility to Masked. Leave Protect variable off, or only protected branches can use it. -
Add this job to
.gitlab-ci.yml:notify-failure:stage: .postimage: alpine:3when: on_failurescript:- apk add --no-cache curl jq- |jq -n --arg title "Pipeline failed: $CI_PROJECT_NAME" \--arg message "$CI_COMMIT_REF_NAME: $CI_COMMIT_TITLE" \--arg url "$CI_PIPELINE_URL" \'{title: $title, message: $message, priority: "important", tags: ["gitlab"],url: $url, url_title: "Open pipeline"}' |curl --fail-with-body -sS https://api.pocketbell.dev/v1/messages \-H "Authorization: Bearer $POCKETBELL_KEY" \-H "Content-Type: application/json" \--data @-
How it behaves
Section titled “How it behaves”.postis the stage GitLab runs last, andwhen: on_failureruns the job only when something before it failed.jq --argturns each value into a JSON string, so a commit title with quotes in it still makes a valid request.- For a notification when a deploy finishes, add a second job with
when: on_successandpriority: "normal".
If nothing arrives
Section titled “If nothing arrives”The job’s log shows Pocketbell’s answer:
- 401
invalid_api_key: the variable is missing, or it’s protected and this branch isn’t. - 400
invalid_request:detailsin the answer names the field.