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 Smart Mirroring in Bitbucket Data Center and Server. 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 Data Center and Server documentation.


Prerequisites

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


To enable Smart Mirroring in Bamboo: 

  1. From the Bamboo header select Administration () > Build resources > Linked repositories.
  2. Select your Bitbucket Data Center and 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 Data Center and 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 Data Center and Server instance. 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 Data Center and 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 Data Center and Server repositories, so they start using the provided mirror.

    {
    	mirrorId:"MIRROR_ID",
    	ignoreErrors: true
    }

    This will tell all repositories linked to a given Bitbucket Data Center and Server Application Link 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 Data Center and 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 Data Center and Server, together with their IDs:

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

Downgrading from Bitbucket Data Center and Server 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.

Last modified on Oct 4, 2022

Was this helpful?

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