Bitbucket New Repo Provisioning and Standards
When a new Bitbucket repository is created (or requested via a Form/approval), the flow applies the standard setup — branch protections, default reviewers, README/CI template files, labels — adds the team, records it in a Dataverse repo registry, and notifies the requester in Teams. Ensures every new repo starts compliant.
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 ensures every new Bitbucket repository starts compliant. A developer (or an upstream Form/app) creates a Repo Request row in a Dataverse registry table. The flow picks it up, asks a platform admin to approve, and on approval creates the repository, applies the standard branch protections on main (required approvals, passing builds, no force-push), seeds a standard README, records the result in the registry, and notifies the requester and the platform Teams channel. If rejected, it marks the request and notifies without creating anything.
Why it matters: Repos created ad-hoc skip protections and conventions, accruing risk and inconsistency. Templated, approval-gated provisioning bakes in standards from commit one and leaves a governed audit trail in Dataverse.
Status: Built · Ships Off (demo). Going live requires only authorizing the connections, setting the environment variable values, and registering the upstream request intake.
Use Case
A platform/IT team wants developers to request a repository and receive a fully-configured, governed repository automatically — without a human manually clicking through Bitbucket settings each time. The Dataverse table doubles as the request intake and the repo registry/audit log.
Flow Architecture
When a Repo Request is Created
Dataverse SubscribeWebhookTrigger (message = Create) on flowlibs_reporequestA developer or upstream Form/app creates a Repo Request row; the new request row is delivered inline.
Setup variables
Initialize Variable (chain)Mint a correlationId (guid()), derive repo name and URL-safe slug, capture the requester email and target Bitbucket project key, and bind workspace, API base, access token, required approvals, approver, Teams group/channel, and the README body to environment variables.
Pre-approval
Dataverse UpdateRecord + Approvals StartAndWaitForAnApproval (Basic)Set the request status to Pending Approval (stamp correlation id + slug), then route a provisioning approval to the platform admin with a summary of the repo and the standards to apply.
If approved — provision
HTTP (Bitbucket REST) + Dataverse UpdateRecord + Teams + OutlookCreate the private repository, apply main branch protections (require approvals, require passing builds, block force-push), commit a standard README (initial commit + main branch), update the registry row to Provisioned with repo URL/approver/standards summary, post Teams success, and email the requester.
If rejected
Dataverse UpdateRecord + Teams + OutlookMark the request Rejected (approver), post a Teams notice, and email the requester — without creating anything.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_BitbucketWorkspace | String | your-workspace | Bitbucket workspace the repo is created in |
| flowlibs_BitbucketApiBaseUrl | String | https://api.bitbucket.org/2.0 | Bitbucket REST base URL (includes /2.0) |
| flowlibs_BitbucketAccessToken | String | REPLACE_WITH_BITBUCKET_ACCESS_TOKEN | Bearer credential for Bitbucket REST calls |
| flowlibs_TeamsGroupId | String | REPLACE_WITH_TEAMS_GROUP_ID | Teams team/group ID for the notifications channel |
| flowlibs_TeamsChannelId | String | REPLACE_WITH_TEAMS_CHANNEL_ID | Teams channel ID for notifications |
| flowlibs_ApprovalAssignedTo | String | platform-admin@your-tenant.onmicrosoft.com | Approver email |
| flowlibs_RequiredApprovalsCount | String | 2 | Required PR approvals enforced on main |
| flowlibs_DefaultReviewers | String | [] | JSON array of Bitbucket account UUIDs for default reviewers (extension point) |
| flowlibs_TemplateFiles | String | # Repository … | Markdown body committed as the standard README.md |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Microsoft Dataverse | shared_commondataserviceforapps | SubscribeWebhookTrigger UpdateRecord |
| Approvals | shared_approvals | StartAndWaitForAnApproval |
| Microsoft Teams | shared_teams | PostMessageToConversation |
| Office 365 Outlook | shared_office365 | SendEmailV2 |
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.
- Branch patterns
- Add more branch-restrictions calls for develop/release/*, or change the pattern from main.
- Default reviewers
- Populate flowlibs_DefaultReviewers and add a POST …/default-reviewers/{uuid} call per reviewer in the Yes branch.
- Template files
- The README commit is the pattern; add more …/src commits (e.g. bitbucket-pipelines.yml, CODEOWNERS) driven by a JSON flowlibs_TemplateFiles.
- Language scaffolds
- Branch on flowlibs_language to commit stack-specific templates.
- Naming convention
- Enforce a repo naming rule in Initialize Repo Slug (e.g. prepend the team).
- Request intake
- Point a Microsoft Form or Power App at the flowlibs_reporequest table to collect requests; the flow triggers on row creation either way.
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.01Repo slug
URL-safe slug from the requested repo name.
EXPR.02Approval gate
Branches on the approval outcome.
EXPR.03Required approvals as integer (HTTP body)
Coerces the env-var value to an integer for the branch-restriction body.
EXPR.04Repo URL
Constructs the new repository URL.
EXPR.05README commit body (form-encoded)
Form-encoded body for the …/src commit.
EXPR.06Bearer auth header
Authorization header for the Bitbucket REST calls.
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.