Clone Azure Repository

Action ID: azure:repo:clone
NPM Package:

@parfuemerie-douglas/scaffolder-backend-module-azure-repositories

Description

Clone an Azure repository into the workspace directory.

Input Schema

PropertyTypeDescriptionRequired
tokenstringThe token to use for authorization.
branchstringThe branch to checkout to.
serverstringThe hostname of the Azure DevOps service. Defaults to dev.azure.com
remoteUrlstringThe Git URL to the repository.
targetPathstringThe subdirectory of the working directory to clone the repository into.

Output Schema

No output schema defined for this action.

Usage Examples

Clone a private Azure DevOps repo alongside a fetched template

This clones a private Azure DevOps repository into a subdirectory while also fetching a starter template with fetch:template. Use this when you scaffold around an existing codebase without overwriting workspace files.

Copy
steps:
  - id: fetchBase
    action: fetch:template
    input:
      url: ./skeleton
      targetPath: .

  - id: cloneServiceRepo
    action: azure:repo:clone
    input:
      remoteUrl: https://dev.azure.com/acme/Payments/_git/payments-service
      targetPath: service
      token: ${{ secrets.azure.token }}

Clone a specific branch into a subdirectory for vendor code

This checks out a specific release branch into a vendor folder. Use this to pin dependencies or SDKs at a known version.

Copy
steps:
  - id: cloneVendorSdk
    action: azure:repo:clone
    input:
      remoteUrl: https://dev.azure.com/acme/Platform/_git/payments-sdk
      branch: release/2024-10
      targetPath: vendor/payment-sdk
      token: ${{ secrets.azure.token }}

Clone from a self hosted Azure DevOps Server

This clones from an on premises Azure DevOps Server using a custom hostname. Use this when your repos are hosted outside dev.azure.com.

Copy
steps:
  - id: cloneLegacyService
    action: azure:repo:clone
    input:
      remoteUrl: https://azure.company.local/DefaultCollection/Manufacturing/_git/LegacyMES
      branch: develop
      targetPath: legacy-mes
      server: azure.company.local
      token: ${{ secrets.azure.serverPat }}

Clone multiple repositories for a composite build

This clones two repositories into separate subdirectories. Use this to assemble a workspace that combines a service and a shared library.

Copy
steps:
  - id: cloneSharedLib
    action: azure:repo:clone
    input:
      remoteUrl: https://dev.azure.com/acme/Shared/_git/node-shared-lib
      branch: main
      targetPath: src/libs/shared
      token: ${{ secrets.azure.token }}

  - id: cloneInventoryService
    action: azure:repo:clone
    input:
      remoteUrl: https://dev.azure.com/acme/Inventory/_git/inventory-service
      branch: main
      targetPath: src/services/inventory
      token: ${{ secrets.azure.token }}

Parameterized clone using user selected repo and branch

This uses template parameters to select the repo, branch, and destination directory at runtime. Use this when the template needs to work with different teams and repositories.

Copy
steps:
  - id: cloneSelectedRepo
    action: azure:repo:clone
    input:
      remoteUrl: ${{ parameters.repositoryUrl }}
      branch: ${{ parameters.branchName }}
      targetPath: ${{ parameters.destinationPath }}
      token: ${{ secrets.azure.token }}