Bitbucket Pipeline Failure to Teams and Jira
When a Bitbucket Pipelines build fails on a protected branch, the flow posts the failure (branch, commit, author, failing step, logs link) to a Teams dev channel and opens or updates a Jira bug assigned to the author. Resolving the build closes the bug. Bridges CI failures to triage and tracking.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This flow bridges Bitbucket Pipelines failures to triage and tracking. When a build changes state on a protected branch, Bitbucket posts a commit-status webhook to the flow. If the build failed, the flow opens (or updates) a Jira bug assigned to the author and posts a failure card to a Microsoft Teams dev channel; when the build recovers, it transitions the bug to Done and closes it. A Dataverse ledger keyed by repo|branch makes the whole thing idempotent, so a flapping build updates one bug instead of spawning duplicates.
Why it matters: Broken builds on main are urgent but easy to miss in email. Routing to Teams plus a tracked, auto-closing Jira bug ensures every failure is seen, owned, and resolved.
Status: Built — ships Off (demo). Going live requires only connection authorization, env-var configuration, and registering the Bitbucket webhook.
Use Case
A development team on Bitbucket Cloud wants CI failures on protected branches surfaced in Teams and tracked as Jira bugs automatically, with the bug closing itself once the build is green again.
Flow Architecture
When a Pipeline Build Status Is Received
Request / Http (webhook)Bitbucket's repo:commit_status_updated event POSTs the build status (state, name, url, refname, commit, author, repository) to the flow URL on every build state change.
Parse the webhook payload
Initialize VariableMint a correlationId (guid()) and parse build state (upper-cased), branch, repository, author, build url, and the repo|branch bug key; bind the reused Teams group/channel and Jira instance env vars.
Condition Is Protected Branch
Condition (If)contains(split(ProtectedBranches), branch) — non-protected branches are acknowledged and ignored (Response 200 + Terminate).
List PRs + search existing bug
Bitbucket ListPullRequests + Dataverse ListRecordsList the repo's open PRs to note which are affected, and find an open ledger row for repo|branch in the Dataverse idempotency ledger.
Build failed
Jira CreateIssue_V3 / AddComment_V2 + Dataverse CreateRecord/UpdateRecord + TeamsIf the build failed: with an existing bug, comment on it (AddComment_V2), bump the failure count, and re-notify; with no bug, compose Jira fields, create a new bug (CreateIssue_V3), record it in the ledger, and alert the channel.
Build recovered
Jira UpdateTransition / AddComment_V2 + Dataverse UpdateRecord + TeamsIf the build is SUCCESSFUL and an open bug exists, transition the bug to Done, add a resolved comment, mark the ledger Closed, and notify.
Respond Ack
Response 200Acknowledge the processed webhook.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_ProtectedBranches | String | main,master,develop | Comma-separated branch names whose failures are tracked |
| flowlibs_JiraAssigneeAccountId | String | REPLACE_WITH_JIRA_ACCOUNT_ID | Jira Cloud accountId the bug is assigned to |
| flowlibs_JiraDoneTransitionId | String | 31 | Jira transition id used to close the bug on recovery |
| flowlibs_TeamsGroupId | String | REPLACE_WITH_TEAMS_GROUP_ID | Teams group/team for the dev channel |
| flowlibs_TeamsChannelId | String | REPLACE_WITH_TEAMS_CHANNEL_ID | Teams channel id |
| flowlibs_BitbucketWorkspace | String | your-workspace | Bitbucket workspace (account) slug |
| flowlibs_JiraInstance | String | REPLACE_WITH_JIRA_INSTANCE_ID | Jira Cloud instance id → X-Request-Jirainstance header |
| flowlibs_JiraProjectKey | String | REQ | Jira project key for the bug |
| flowlibs_JiraBugIssueTypeId | String | 10004 | Numeric Jira issue-type id (Bug) |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Bitbucket | shared_bitbucket | ListPullRequests |
| Microsoft Teams | shared_teams | PostMessageToConversation |
| Jira | shared_jira | CreateIssue_V3 AddComment_V2 UpdateTransition |
| Microsoft Dataverse | shared_commondataserviceforapps |
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Per-author assignment
- Replace the single flowlibs_JiraAssigneeAccountId with a lookup (Dataverse table or env-var JSON map) from Bitbucket display name → Jira accountId so the bug routes to the real author.
- Severity / on-call escalation
- Escalate main-branch failures to an on-call group (e.g. Teams mention or PagerDuty) when Failure Count exceeds a threshold.
- Auto-revert
- On repeated failures, open a revert PR via the Bitbucket connector.
- Flaky detection
- Track intermittent failures by comparing consecutive states on the same commit and tag the bug.
- Resolution status
- Drive flowlibs_JiraDoneTransitionId and an optional resolution field from env vars to match your Jira workflow.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Protected-branch gate
Only protected-branch failures are tracked.
EXPR.02Idempotency key
repo|branch key making the flow idempotent.
EXPR.03Open-bug test
True when an open ledger row already exists.
EXPR.04Build recovered
Recovery only when the build is green and an open bug exists.
EXPR.05Failure count bump
Increments the failure count on a recurring failure.
Customize & download
Generate a ready-to-import copy of this solution with your environment-variable values baked in — available on Base, Pro, or Team.
Upgrade to customize
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.