Skip to content
LastPing
GUIDE · BITBUCKET PIPELINES · FREE

Monitor Bitbucket Pipelines, and get told why a pipeline failed

Add an after-script block and a success ping to your bitbucket-pipelines.yml, plus a heartbeat watchdog in LastPing. Every pipeline run confirms in; a run that fails, hangs, or never starts opens an incident with failure detail. Free for individuals, no monitor cap.

Your assistant can do this for you

Monitor my Bitbucket Pipelines with LastPing

On this page
  1. Bitbucket Pipelines fails silently in three ways.
  2. Setup: one YAML block, about three minutes
  3. What this catches
  4. Questions people ask

Bitbucket Pipelines fails silently in three ways.

Scheduled pipelines and nightly jobs look healthy in Bitbucket until the moment they aren't, and none of the three common failure modes send you a timely, actionable alert.

Failure mode 01

Build-minute cap hit

Bitbucket Cloud free plans include a fixed number of build minutes per month. When the cap is hit, new pipelines queue and never start. No email to the pipeline owner. Your nightly backup simply stops.

Failure mode 02

Deleted variable or environment

A pipeline that references a repository variable or deployment environment that was renamed, deleted, or access-revoked fails at the first step that needs it, often silently for scheduled runs because the notification only goes to the committer (who isn't one).

Failure mode 03

Hung runner or step

A pipeline step that hangs (a frozen network call, an infinite retry loop, an SSH connection that never times out) runs until Bitbucket's step timeout kills it hours later. Nobody is paged while it waits.

A success ping at the end of a pipeline catches some failures, but only when the pipeline runs at all. A heartbeat watchdog that expects a ping at your pipeline's cadence catches the rest: build-minute caps, deleted variables, and every other reason a pipeline never fires are all caught as a missing signal.

Setup: one YAML block, about three minutes

No Bitbucket add-on required, no API token, no external agent. The after-script block is a Bitbucket Pipelines built-in: it runs after every step, success or failure.

Create a heartbeat monitor in LastPing

In the console, create a monitor, choose Cron job, and set the schedule to match your pipeline schedule. Copy the ping URL.

https://ping.lastping.dev/<uuid>

Add a start ping at the top of your pipeline step

Add a script entry as the first command in your relevant pipeline step. This arms overrun detection: if the step starts but never finishes, the missing completion ping opens an incident.

# bitbucket-pipelines.yml
pipelines:
  custom:
    nightly-backup:
      - step:
          name: Run backup
          script:
            - curl -fsS -m 10 --retry 3 -o /dev/null https://ping.lastping.dev/<uuid>/start
            - # ... your actual commands ...

Add a success ping and failure detail with after-script

The after-script block runs regardless of step outcome. Check BITBUCKET_EXIT_CODE to send either a success ping or a failure POST with context. Up to 10,000 bytes are stored on the open incident.

          after-script:
            - |
              if [ "$BITBUCKET_EXIT_CODE" = "0" ]; then
                curl -fsS -m 10 --retry 3 -o /dev/null \
                  "https://ping.lastping.dev/<uuid>"
              else
                curl -fsS -m 10 -X POST -H "Content-Type: text/plain" \
                  --data "$BITBUCKET_STEP_NAME failed on $BITBUCKET_BRANCH — build $BITBUCKET_BUILD_NUMBER" \
                  "https://ping.lastping.dev/<uuid>/fail"
              fi

Done: every pipeline run now reports in

LastPing receives the start ping, then either a success ping or a fail POST with context. A run that never starts (because of a build-minute cap or any other reason) is caught as a missing signal when the watchdog deadline passes. Alerts go to email, Slack, Discord, Telegram, ntfy, Pushover, Microsoft Teams, Google Chat or a signed webhook.

What this catches

The same durable detection engine as LastPing's cron monitoring: deadlines live in the database, so a restart never misses a due check.

  • Failed steps: the after-script fires and POSTs the failure detail; an incident opens with step name, branch, and build number attached.
  • Hung steps: a step that reports a start ping but never completes; the missing completion ping opens an incident after the grace window.
  • Pipelines that never start: build-minute cap, deleted variable or environment, or a YAML syntax error. No ping in the expected window → incident.
  • Recovery: the next successful completion ping closes the incident and sends a recovery notice. No manual reset.
  • Flap protection: a step that fails and immediately recovers within the damping window doesn't page you.

For CI/CD pipelines with native signed-webhook support in LastPing, see GitHub Actions, GitLab CI, and Jenkins. Other platforms: CircleCI, Drone CI, TeamCity. AI agents can self-register their own monitors via MCP.

Questions people ask

Front-loaded answers: the most important fact first.

  • How do I get alerted when a Bitbucket Pipeline fails?

    Add an after-script block to your Bitbucket Pipeline steps that checks BITBUCKET_EXIT_CODE and POSTs failure detail to LastPing's /fail endpoint on failure, and a success curl step at the end of the pipeline. Create a heartbeat monitor in LastPing with your pipeline's schedule so a run that never starts (due to build-minute cap, deleted variable, or runner failure) also opens an incident. Free for individuals, no monitor cap.

  • How do I know if a Bitbucket scheduled pipeline stops running?

    Bitbucket Pipelines can stop firing when you've exhausted your monthly build minutes, when a required repository variable or deployment environment is deleted, or when the pipeline configuration YAML has an error that prevents triggering. Bitbucket does not proactively email you when you approach the build-minute limit, and pipelines that fail to start are not "failures" in the notification sense. A LastPing heartbeat monitor expects a ping at your scheduled cadence and opens an incident when the expected signal doesn't arrive, regardless of why: that covers a credit cap, a deleted variable, and any other reason the pipeline never fires.

  • What is an after-script in Bitbucket Pipelines, and what is BITBUCKET_EXIT_CODE?

    An after-script block in bitbucket-pipelines.yml runs after the main steps regardless of whether they succeed or fail, similar to a 'finally' block. BITBUCKET_EXIT_CODE is an environment variable Bitbucket Pipelines injects into after-script blocks containing the combined exit code of the preceding script commands. Zero means all commands succeeded; non-zero means at least one failed. Use it to branch between a success ping and a failure POST in a single after-script, so failure detail goes to LastPing only when the pipeline failed.

  • Can I attach the Bitbucket Pipeline failure log to the alert?

    Yes. In an after-script step, check BITBUCKET_EXIT_CODE and POST up to 10,000 bytes of plain text to https://ping.lastping.dev/<uuid>/fail: include the pipeline UUID, step name, branch, build number, and any last-log snippet available in the after-script environment. The body is stored on the open incident in LastPing and shown in the console. It is never logged server-side.

  • Is Bitbucket Pipelines monitoring free in LastPing?

    Yes. LastPing is free for individuals with no monitor cap. The ping endpoint is plain HTTP: no SDK, no agent. GitHub Actions, GitLab CI, and Jenkins are also supported with their native CI webhook patterns. See how it compares to Healthchecks.io and Cronitor, or read the roundup of free cron monitoring tools.

FREE FOR INDIVIDUALS · FULLY HOSTED

Your next silent pipeline failure is already scheduled.

One YAML block now beats a post-mortem later. First alert wired up in about three minutes, and LastPing monitors itself the same way.