Bitbucket To Azure Devops

Bitbucket To Azure Devops

Reading time1 min
#DevOps#Migration#Cloud#AzureDevOps#Bitbucket#CICD

Seamless Migration: Bitbucket to Azure DevOps Without Interrupting CI/CD

Repository migrations often fail at the pipeline layer. Source code is easy to move; operational continuity rarely is. Consider a mid-sprint migration: if pipeline automation breaks, delivery halts and triage time multiplies.


Beyond Repo Sync: The Real Work

Copying a Git repository is trivial. Reconstructing end-to-end build, test, and deploy automation—especially under live deadlines—requires deliberate sequencing. Modern teams rely on triggers, secrets, build agents, and downstream integrations (artifact feeds, Docker registries, third-party build checks). Any gap can block releases or corrupt artifacts.

A typical outage: A build step references a service connection no one migrated, or an environment variable hardcodes an obsolete Bitbucket secret. Rewrites after the fact are costly.

Critical path: Replicate (and validate) pipelines before cutover, using shadow environments.


1. Azure DevOps Onboarding: Lay the Groundwork

Initial setup impacts downstream security and maintenance.

  • Project Creation: In Azure DevOps (https://dev.azure.com/), create a new Project per business unit or product—avoid overstuffed monoliths.
  • Repo Structure: Use the Azure Repos UI to prepare new Git repos, matching Bitbucket repo names for migration clarity. (Gotcha: Azure disallows uppercase or special characters in repo names by default.)
  • Identity/Access: Populate teams and map existing Bitbucket roles. Azure DevOps uses AAD Groups by default; sync via AAD Connect if on hybrid identity.

2. Repository Mirror: Git, No Surprises

Migration is deterministic if mirroring is respected. Use the following to preserve all refs, branches, and tags—critical for release traceability.

# Local mirror of a Bitbucket repo (shallow clones risk data loss)
git clone --mirror https://bitbucket.org/acme/backend-api.git
cd backend-api.git

# Push to Azure DevOps remote (replace; do not merge)
git push --mirror https://dev.azure.com/org/proj/_git/backend-api

--mirror includes refs and hooks but does not migrate Bitbucket pull requests, wiki, or issue history.

Known issue: Azure DevOps sometimes rejects large repos with >2GB history by default. Chunk if necessary, or contact Microsoft support for quota increases.


3. Pipeline Forensics: Inventory and Map Automation

Most breakage happens here. Bitbucket Pipelines (bitbucket-pipelines.yml) and Bamboo jobs use a different execution model than Azure Pipelines.

  • Inventory Build Logic: Catalog each pipeline, noting triggers (on: pull_request, schedules), build matrices, secrets injection, and external scripts.
  • Step Translation: Azure uses YAML pipelines (.azure-pipelines.yml) with a distinct syntax and pool configuration. Example for Node.js 16 on Ubuntu 22.04:
trigger:
  branches:
    include:
      - main

pool:
  vmImage: 'ubuntu-22.04'

steps:
  - task: NodeTool@0
    inputs:
      versionSpec: '16.x'
    displayName: 'Setup Node 16'

  - script: |
      npm ci
      npm run build
      npm run test
    displayName: 'Build/Test'
Bitbucket FeatureAzure Pipelines Analog
caches (npm, maven)CacheBeta@1 task
Deployment environmentsEnvironment + approval gates
Docker service containerscontainer:/ services:

Not migrated: Bitbucket build logs, pipeline history, or deployment tracking. Archive before disabling Bitbucket.


4. Parallel Validation: Trust, but Verify

Fatal mistake: Trusting green pipelines without real test artifacts.

  • Enable CI triggers in both Bitbucket and Azure for a limited period.
  • Create a throwaway branch. Push, then compare pipeline outputs:
    • Build logs, artifact hashes, generated Docker image digests.
    • Pipeline duration; infra configuration (VM images, secrets).
  • Typical pipeline diff: Azure disables some Bitbucket env vars by default (BITBUCKET_BUILD_NUMBER has no analog; replace with Build.BuildId).

Example failure on first run:

##[error]npm ERR! Missing script: "deploy"

Map all scripts used by custom Bitbucket hooks or scripts.


5. Peripheral Migration: Integrations and Artifacts

CI/CD rarely stands alone.

  • Artifact Storage: Move artifacts from Bitbucket downloads or Bamboo Artifactory to Azure Artifacts or an external registry.
  • Service Connections: Rebuild external service endpoints in Project Settings > Service connections. Missing credentials or outdated subscription IDs cause silent deployment failures.
  • Docker Registry: If using Bitbucket Container Registry, migrate images to Azure Container Registry (az acr import) or artifact registry. For sensitive workloads, confirm that pull secrets are updated across Kubernetes manifests.

6. Final Cutover: Freeze and Observe

Prepared teams coordinate cutover to minimize risk:

  • Announce a freeze window. Block new merges in Bitbucket, temporarily restrict force pushes.
  • Direct all commit and PR activity to Azure DevOps. Monitor commit hooks to ensure no downstream jobs still reference Bitbucket.
  • Monitor: Set up pipeline monitors or dashboards to watch for build anomalies post-migration.
  • For 72h post-cut, expect fast patch cycles—leave both environments available (read-only) for logs and history.

Tips from the Trenches

  • Automate user/project mapping: Scripting via Azure DevOps CLI (az devops) accelerates scale migrations.
  • Partial Rollback: Retain local mirrors of original Git repos until at least two sprint cycles complete cleanly.
  • Wiki/issue data: Not natively portable; 3rd-party tools like Atlassian Bitbucket to Azure DevOps Migration Tools exist, but results may vary.

Observations

Every migration will miss some context—not all hardcoded values or secrets are documented. Shadow CI runs catch most of these, but manual review still surfaces edge cases (e.g. custom Docker build args, platform-specific file permissions). Expect at least one day lost to "why is this variable not set?" debugging.

Some organizations consider running both platforms in parallel for an entire release cycle. This extends support effort but gives confidence, especially if legacy production deployments can’t tolerate risk.


Summary

Shifting from Bitbucket to Azure DevOps is fundamentally about process preservation, not just Git transit. Map automation faithfully, keep pipeline validation side-by-side for as long as possible, and automate wherever you can. The real work is in the details: secrets, hooks, and dependent systems. Anything less invites “why did this break” at 3am—no engineer’s favorite outcome.

Questions on YAML pipeline idiosyncrasies or specific migration blockers? Happy to provide practical samples or troubleshooting specifics.