Skip to content
| Marketplace
Sign in
Azure DevOps>Azure Pipelines>Centralize Repositories
Centralize Repositories

Centralize Repositories

Things U Need

|
2 installs
| (0) | Free
Centralize pipeline-local repositories per software agent
Get it free

Overview

This extension is used to centralize pipeline-local repositories per software agent and save disk space by sharing repositories between different pipelines of the same software agent.

This means that repositories below $(Agent.BuildDirectory) (for example $(Agent.BuildDirectory)/s) can be moved to a centralized location below $(Agent.WorkFolder). This location is only centralized per software agent, and since only one pipeline can run per software agent, there's never the danger of two builds accessing the same centralized repository at the same time. However, you have to make sure that you never move two different repositories of the same name (say from two different team projects) to the same centralized location. Either give them a different name during checkout, or move them to a different centralized (folder) location with the CentralizedLocation option.

This buildstep should be executed after the checkouts of the repositories to centralize.

Inputs

Possible inputs are:

  • DefaultRepository: string, The name for the folder used for the default repository of the current build normaly stored at $(Agent.BuildDirectory)/s in the centralized location. Do not use quotes to define the path. Leave blank or don't provide if you do not want to centralize the default repository. Make sure this name will never be used by another repository on this software agent in the same centralized location. You can use variables , example: MyMainRepo
  • Repositories: string, The name of the repository folders to move to the centralized location. You can separate multiple repository folders with commas. Do not use quotes to define paths. Leave blank or don't provide if you do not want to centralize any other repositories beside the default repository. Make sure these names will not be used by other repositories on this software agent in the same centralized location. You can use variables , example: MyFirstSideRepo, MySecondSideRepo
  • CentralizedLocation: string, The path or folder below $(Agent.WorkFolder) in which to move the centralized repositories to. Do not use quotes to define the path. Default is 'Repositories'. You can use variables
  • UseJunctions: true/false, Should we use junctions instead of symbolic links? Default is false and will use symbolic links.
  • pwsh: true/false, Should Powershell Core be used if it exists? Default is true and will use powershell core. Otherwise the normal Windows Powershell (5) will be used.

Example

This example will check out the default repository to $(Agent.BuildDirectory)/s as well as the repository MyFirstSideRepository to $(Agent.BuildDirectory)/My1stSideRepository and repository MySecondSideRepository to $(Agent.BuildDirectory)/MySecondSideRepository.

It will then centralize these repositories to $(Agent.WorkFolder)/AllMyRepositories/MyMainRepository, $(Agent.WorkFolder)/AllMyRepositories/My1stSideRepository and $(Agent.WorkFolder)/AllMyRepositories/MySecondSideRepository respectively.

Normally $(Agent.WorkFolder) will be the _work directory.

- checkout: self

- checkout: MyFirstSideRepository
  path: My1stSideRepository

- checkout: MySecondSideRepository
  path: MySecondSideRepository

- task: tun.CentralizeRepositories.CentralizeRepositories.CentralizeRepositories@1
  displayName: 'Centralize repositories'
  inputs:
    DefaultRepository: MyMainRepository
    Repositories: My1stSideRepository, MySecondSideRepository
    CentralizedLocation: AllMyRepositories
    UseJunctions: false
    pwsh: true

Notes

  • For angular or node projects you might need to use the --preserve-symlinks switch or the preserveSymlinks options must be set to true in the angular.json file:
    "options": {
      "preserveSymlinks": true
    }
    
  • You need PowerShell Core installed for the default behaviour to work. If the agent is running on a Windows machine and you do not have PowerShell Core installed you can set the pwsh option to false to use the old Powershell 5 shell.
  • If compiling or something else doesn't work with symbolic links, try using junctions instead by setting UseJunctions to true. The main difference for you is that symbolic links will use relative links, so moving the agent root folder around won't break the links, while junctions use absolute paths, which would break the links to the centralized repositories if you move the root folder of the agent.
  • If you do not provide the CentralizedLocation option it will default to $(Agent.WorkFolder)/Repositories as the root for all centralized repositories
  • If you do not provide the DefaultRepository option then the default/self repository at $(Agent.BuildDirectory)/s will not be centralized.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft