Smart Mirroring

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

Starting with version 6.2, Bamboo provides support for Bitbucket Server Smart Mirroring. Smart Mirroring allows you to use local repositories for storing your repository data to avoid having to wait when cloning a repository from a remote location. 

For more on Smart Mirroring, see the Bitbucket Server documentation.


Prerequisites

  • Bitbucket Server 5.0.0 or later
  • Bitbucket Server Data Center license with mirrors support
  • routing from Bamboo to Bitbucket Server instance
  • routing between agent and mirror enabled


To enable Smart Mirroring in Bamboo: 

  1. From the Bamboo header select  > Build resources > Linked repositories.
  2. Select your Bitbucket Server repository. 
  3. In the Edit repository section, select Advanced options.
  4. From the Mirror drop-down list, select your mirror location.

    Repository mirror location selection

Bulk update of Smart Mirroring settings for repositories

Starting from Bamboo 6.10.3, you can update the mirrors for all repositories of a single Bitbucket Server.


Click here for details...

You can update the Mirror field value by using the following REST endpoint:

POST /rest/stash/latest/bulk/APPLICATION_LINK_ID/mirror  

  • APPLICATION_LINK_ID: the ID of a linked Bitbucket Server. Read below for more info on how to find it.
Payload format
  1. Perform a dry run (without an actual update), and reset all repositories to the master node. This will allow you to disable the usage of mirrors for all Bitbucket Server repositories in Bamboo.

    {
    	resetToPrimary:true,
    	dryRun:true
    }

    Here's a sample output:

    {
      "size": 21,
      "limit": 21,
      "lastPage": true,
      "start": 0,
      "values": [
        {
          "id": 1770061851,
          "name": "Bamboo Version Stable",
          "global": false,
          "selfUrl": "http://BAMBOO_URL/chain/admin/config/editChainRepository.action?buildKey=ZJM-VCT",
          "oldMirrorId": "",
          "oldMirrorName": "",
          "newMirrorId": "primary",
          "newMirrorName": "Primary"
        },
        {
          "id": 2357198853,
          "name": "bamboo-stash-plugin",
          "global": true,
          "selfUrl": "http://BAMBOO_URL/admin/editLinkedRepository.action?repositoryId=2357198853",
          "newMirrorId": "primary",
          "newMirrorName": "Primary"
        },
        {
          "id": 1642397765,
          "name": "bamboo-doc-code",
          "global": true,
          "selfUrl": "http://BAMBOO_URL/admin/editLinkedRepository.action?repositoryId=1642397765",
          "newMirrorId": "primary",
          "newMirrorName": "Primary"
        },
        {
          "id": 1775861823,
          "name": "bamboo-some-code",
          "global": true,
          "selfUrl": "http://BAMBOO_URL/admin/editLinkedRepository.action?repositoryId=1775861823",
          "oldMirrorId": "",
          "oldMirrorName": "",
          "newMirrorId": "primary",
          "newMirrorName": "Primary"
        },
        {
          "id": 2439381015,
          "name": "static assets",
          "global": false,
          "selfUrl": "http://BAMBOO_URL/chain/admin/config/editChainRepository.action?buildKey=TEST-CIWEBDRIVERCDN",
          "newMirrorId": "primary",
          "newMirrorName": "Primary"
        },
        {
          "id": 1738702849,
          "name": "atlassian-plugin",
          "global": true,
          "selfUrl": "http://BAMBOO_URL/admin/editLinkedRepository.action?repositoryId=1738702849",
          "oldMirrorId": "BFHH-O74T-KDGH-CT47",
          "oldMirrorName": "US East Mirror",
          "newMirrorId": "primary",
          "newMirrorName": "Primary"
        }
    ]
  2. Update all Bitbucket Server repositories, so they start using the provided mirror.

    {
    	mirrorId:"MIRROR_ID",
    	ignoreErrors: true
    }

    This will tell all repositories linked to a given Application Link Bitbucket Server to use the provided mirror. The ignoreErrors flag allows to skip updating repositories that aren't supported by the given mirror. The response will contain all affected repositories.

Obtaining the Bitbucket Server Application Link value

Use the following snippet to print the list of all Bitbucket Server instances known to Bamboo, together with their Application Link IDs:

curl -H "Content-Type: application/json" -H "Accept: application/json" http://BAMBOO_URL/rest/stash/latest/servers


Obtaining the Mirror ID value:

Use the following snippet to print the mirror servers that are configured in Bitbucket Server, together with their IDs:

curl -H "Accept: application/json" https://BITBUCKET_SERVER_URL/rest/mirroring/latest/mirrorServers

Downgrading from Bitbucket Server Data Center license to a regular license may cause problems. In the unlikely event of such a downgrade, we recommend to switch all repositories to primary before switching versions.

Downgrading from Bitbucket Server Data Center from version 5+ to version 4 may cause problems. In the unlikely event of such a downgrade, we recommend to switch all repositories to primary before switching versions.



Last modified on Apr 11, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.