The moment it happens
Get an email when a Bitbucket build fails
As soon as a pipeline or build fails, you get the commit and the pull request it belongs to.
- Runs
- The moment it happens
- Apps
- Bitbucket
- AI
- Not needed
- Access
- read:repository, read:pullrequest
Send this to your assistant
Create a ClickRuntime automation: whenever a build on our acme/web-app Bitbucket repo fails, email me the commit message, the author and a link to the pull request it belongs to.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A Bitbucket pipeline fails at 6 pm after a developer has pushed and left for the day. The red cross appears on the commit, but nobody is looking at it. The next morning the main branch is still broken, three more people have pushed on top of it and the cause is now buried under several commits, which turns a five-minute fix into an hour of detective work.
When Bitbucket reports a pipeline state change, ClickRuntime receives the event at once and keeps only those with the state FAILED. It then looks up any pull requests tied to the failing commit and sends a notification that names the repository, the branch and the pull request, so the right person knows their change is the one that broke.
Teams that rely on pipelines for tests and deployment, and want broken builds treated as an immediate problem, are the natural users.
What you get out of it
Broken builds are fixed while they are fresh
The author is told while the change is still in their head. A fix pushed within minutes is far cheaper than debugging after several unrelated commits have piled up on top.
The right person is pointed to the cause
Looking up the pull request attached to the commit means the message identifies whose change failed. Nobody has to scroll the pipeline list to figure out who should look. That saves a round of questions in chat when several people pushed close together.
Main stays releasable
A failure on the main branch blocks deployments. Hearing about it right away keeps the release path clear and avoids a hotfix that is held up by a red build nobody noticed.
Failed deployments get caught after hours
Pipelines that deploy on merge can fail in the evening. An alert makes sure a failed production deploy is known to someone before customers feel it. Waking up to a customer report is a worse way to learn about it.
Fewer repeated broken pushes
When the team sees a red build announced, others hold off merging on top of it. That discipline stops the cascade of commits that make a simple failure hard to diagnose.
How it works
What happens, step by step
When a build status changes in Bitbucket, Bitbucket tells ClickRuntime straight away.
ClickRuntime ignores everything except failed builds.
It looks up the commit and the pull request it belongs to.
You get an email with the build name, repository, commit message and a link to the pull request.
Before it runs live
- Connect Bitbucket
- Paste your automation's link into the other app's webhook settings
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Act only on the items that match your own rules, and skip the rest
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Bitbucket steps into one automation
Under the hood
The code that runs this automation
from clickruntime import on_event, credentials, http, notify
BB = "https://api.bitbucket.org/2.0"
def bb(path, **params):
resp = http.get(f"{BB}{path}", headers={"Authorization": f"Bearer {credentials.secret('BITBUCKET_TOKEN')}"}, params=params)
resp.raise_for_status()
return resp.json()
@on_event
def handle(event):
status = event.json.get("commit_status", {})
if status.get("state") != "FAILED":
return {"skipped": status.get("state")}
repo = event.json["repository"]["full_name"]
commit = status["commit"]
prs = bb(f"/repositories/{repo}/commit/{commit['hash']}/pullrequests").get("values", [])
pr = prs[0]["links"]["html"]["href"] if prs else "no pull request"
notify.email_me(f"Build failed: {status['name']} on {repo}",
f"{commit['message'].strip()}\nAuthor: {commit['author']['raw']}\nPR: {pr}\nBuild: {status['url']}")
return {"commit": commit["hash"]}FAQ
Common questions
Does it alert on every pipeline run or only failures?
What if the failing commit has no pull request?
Does it need a webhook set up in Bitbucket?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Post new Bitbucket pull requests to Slack
Each newly opened pull request shows up in your team channel with its author and reviewers.
See how it worksGet a morning list of pull requests waiting too long
Every weekday you see which pull requests have been open for more than three days, so reviews do not stall.
See how it worksGet a weekly pull request report per repo
Each Monday you see how many pull requests were opened, merged and declined in every repo last week, and by whom.
See how it worksKeep exploring
Set up “Get an email when a Bitbucket build fails” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.