Integrate Spike with Bitbucket Pipelines
Send Bitbucket Pipelines build failures to Spike so on-call is paged on phone, SMS, Slack or Teams, and incidents resolve when the pipeline goes green again.
Bitbucket Pipelines reports the outcome of every run back to the commit it built, and Bitbucket sends that outcome out as a webhook. Spike listens to those build status events, so a failed pipeline opens an incident that escalates through your on-call policy, and the next successful run of the same pipeline on the same branch closes it.
You can wire this up for a single repository, or once for a whole workspace so every repository in it reports to the same Spike service.
What Spike does with each build status
Bitbucket sends a build status as repo:commit_status_created when a run starts reporting and repo:commit_status_updated when it finishes. Spike handles both and reacts to the state on them:
FAILED
Opens an incident for that repository, branch and pipeline, or adds an event to the one already open
SUCCESSFUL
Auto-resolves the open incident. Dropped when nothing is open
INPROGRESS
Ignored. A run that is still going never pages anyone
STOPPED
Ignored. A cancelled run is not a failure
There is one incident per repository, branch and pipeline. A branch that keeps failing on every push groups into that one incident instead of paging the team again and again, and the first green run on the same branch resolves it.
Incident titles stay the same across repeats, which is what makes them readable when Spike reads one out on a phone call:
Pipeline failed on main in acme/checkout-apiEach incident carries the detail on its page rather than in the title:
Repository, with a link to it in Bitbucket
Branch the run was on
Commit hash, with a link to the commit
Commit author, as reported by Bitbucket
A link straight to the pipeline run, so on-call lands on the failing step
The build status name and description Bitbucket sent
Prerequisites
A Bitbucket Cloud account with admin access on the repository, or on the workspace for a workspace-wide webhook
At least one pipeline defined in
bitbucket-pipelines.ymlA Bitbucket Pipelines integration in Spike and its webhook URL
Step 1 — Create the integration in Spike
In Spike, go to Integrations → Add integration → Bitbucket Pipelines, attach it to a service and an escalation policy, and copy the webhook URL. It looks like https://hooks.spike.sh/<your-token>/push-events.
Step 2 — Add the webhook in Bitbucket
Pick one of the two below. A repository webhook covers one repository, a workspace webhook covers every repository in the workspace.
Use this when different repositories should page different teams, or when you only want a few repositories in Spike.
Open the repository in Bitbucket and go to Repository settings → Webhooks.
Click Add webhook.
Fill in the form:
Title:
SpikeURL: the webhook URL you copied in Step 1
Status: leave Active ticked
SSL / TLS: leave certificate validation enabled
Under Triggers, choose Choose from a full list of triggers, and in the Repository section tick:
Build status created
Build status updated
Click Save.
Repeat this for every repository you want in this Spike integration. Repositories that should page a different team get their own Spike integration and their own webhook URL.
Use this when every repository in the workspace should page the same team. One webhook, one Spike integration, no per-repository setup as the workspace grows.
From your workspace in Bitbucket, go to Workspace settings → Webhooks.
Click Add webhook.
Fill in the form:
Title:
SpikeURL: the webhook URL you copied in Step 1
Status: leave Active ticked
SSL / TLS: leave certificate validation enabled
Under Triggers, choose Choose from a full list of triggers, and in the Repository section tick:
Build status created
Build status updated
Click Save.
Every repository in the workspace now reports to this one integration, and Spike still opens a separate incident per repository and branch.
Do not point both a workspace webhook and a repository webhook at the same Spike integration for the same repository. Bitbucket would deliver every build status twice. The incidents still group, so you would not be paged twice, but the incident timeline fills with duplicate events.
Step 3 — Check it works
Push a commit to a branch whose pipeline you expect to fail, or temporarily add a step that exits non-zero.
When the run turns red, the incident shows up in Spike with the repository, branch and a link to the run.
Fix the branch and push again. The green run resolves that incident.
If nothing arrives, open the webhook in Bitbucket and click View requests to see the deliveries and the response Spike returned.
Event payload structure
Bitbucket sends the event key in the X-Event-Key header and a JSON body. Abridged to the parts Spike reads:
Key fields:
commit_status.state—FAILED,SUCCESSFUL,INPROGRESSorSTOPPED. This is what decides whether Spike opens, resolves or dropscommit_status.name— the pipeline and run number, used in the incidentcommit_status.url— link to the pipeline runcommit_status.refname— the branch, used for groupingcommit_status.commit.hash— the commit that was builtrepository.full_name— workspace and repository, used for groupingactor.display_name— who pushed the commit that started the run
Fields Bitbucket leaves out are simply left off the incident.
Troubleshooting
Last updated
Was this helpful?