238b49a04a
Feature/DAIP2-1575 set up dev prod uat branches * Add branch promotion gates and release pipelines * Add resolve_source_branch.sh script and update .gitignore; fix pipeline step name casing 'dev' * Add AI code review step and refactor branch resolution in pipelines * Merged dev into feature/DAIP2-1575-set-up-dev-prod-uat-branches- * Merged dev into feature/DAIP2-1575-set-up-dev-prod-uat-branches- * Merged dev into feature/DAIP2-1575-set-up-dev-prod-uat-branches- Approved-by: Katon Minhas
5.1 KiB
5.1 KiB
CI/CD Branching, Promotion, Release, and Rollback Strategy
This document describes the current Bitbucket CI/CD implementation and branch governance configured for this repository. It reflects the intended promotion model shown in the attached strategy image.
1) Strategy Overview
Branch model
feature/*andbugfix/*are short-lived development branches.devis the integration branch.stgis the pre-production validation branch.mainis the production release branch.hotfix/*supports emergency fixes with controlled promotion.
Promotion paths (as implemented)
feature/*->Developbugfix/*->Developdev->Stagingstg->main
Hotfix paths
hotfix/*->main(direct emergency production fix)hotfix/*->dev(back-merge / forward-fix alignment)
2) Pull Request Pipeline Controls
Defined under pipelines.pull-requests in bitbucket-pipelines.yml.
A. Source branch gate by pattern
feature/*: pipeline fails unless destination isdevbugfix/*: pipeline fails unless destination isdevhotfix/*: pipeline fails unless destination ismainordevdev: pipeline fails unless destination isstgstg: pipeline fails unless destination ismain
B. Branch naming validation for all PRs
The "**" PR pipeline validates source branch naming convention:
- Allowed:
feature/<description> - Allowed:
bugfix/<description> - Allowed:
hotfix/<description>
Any other source branch naming pattern is blocked.
3) Repository Branch Restrictions (Bitbucket Settings)
The following controls are enforced through repository settings (in addition to pipeline checks).
3.1 dev
- Direct write access: restricted
- Deletion: not allowed
- History rewrite: not allowed
- Merge via PR only
- Merge checks:
- minimum 1 approval
- minimum 1 default reviewer approval
- unresolved PR tasks not allowed
- last commit must have successful build
3.2 stg
- Direct write access: restricted
- Deletion: not allowed
- History rewrite: not allowed
- Merge via PR only
- Merge checks:
- minimum 2 approvals
- minimum 1 default reviewer approvals
- unresolved PR tasks not allowed
- last commit must have successful build
3.3 main
- Direct write access: restricted
- Deletion: not allowed
- History rewrite: not allowed
- Merge via PR only
- Merge checks:
- minimum 2 approvals
- minimum 1 default reviewer approvals
- unresolved PR tasks not allowed
- last commit must have successful build
3.4 feature/*
- Write access: broader (Everybody)
- Deletion: not allowed
- History rewrite: not allowed
- Merge to protected branches is still controlled by PR destination branch restrictions and PR pipeline gates.
3.5 bugfix/*
- Write access: limited to authorized users/groups
- Deletion: not allowed
- History rewrite: not allowed
3.6 hotfix/*
- Write access: limited to authorized users
- Deletion: not allowed
- History rewrite: not allowed
- PR merges additionally require build success and at least 1 approval (as configured).
4) End-to-End Flow (Aligned to Strategy Image)
flowchart LR
FB[feature/* or bugfix/*] -->|PR + checks| D[dev]
D -->|PR + stricter checks| S[stg]
S -->|PR + strictest checks| M[main]
H[hotfix/*] -->|PR + checks| M
H -->|PR + checks| D
Control layering
Each promotion is protected by two layers:
- Pipeline gate validates source/destination path and syntax/build health.
- Branch restriction gate enforces approvals, reviewers, task completion, and successful build before merge.
5) Release to Production (Custom Pipeline)
Custom pipeline: release-prod
Behavior
- Enforces execution from
mainonly. - Reads latest tag matching
v*. - Calculates next version using
RELEASE_TYPE:major: increments major, resets minor/patch to 0.minor: increments minor, resets patch to 0.
- Creates and pushes annotated tag.
- Deploys using repository variable
DEPLOY_COMMANDwithRELEASE_TAG.
Inputs
RELEASE_TYPE(majororminor, defaultminor)
Required variable
DEPLOY_COMMAND(must consumeRELEASE_TAG)
6) Rollback in Production (Custom Pipeline)
Custom pipeline: rollback-prod
Behavior
- Enforces execution from
mainonly. - Validates
ROLLBACK_TAGis provided. - Validates tag exists in repository.
- Re-deploys by setting
RELEASE_TAG=ROLLBACK_TAGand executingDEPLOY_COMMAND.
Input
ROLLBACK_TAG(example:v2.3.0)
7) Operational Notes
- Branch names in pipeline checks are case-sensitive; current gates use
DevelopandStaging(capitalized). - Branch restriction and pipeline branch names must remain consistent to avoid false gate failures.
- Production deployments should be traceable by release tag and deployment record.
8) Governance Summary
This setup enforces controlled upward promotion (feature/bugfix -> Develop -> Staging -> main), allows emergency hotfix routing, and combines:
- structural branch protections,
- approval/workflow controls,
- automated PR validation,
- and auditable tagged production release/rollback execution.