0

I have an azure devops multi-stage pipeline which requires 1 stage that copies files from another repository to $(build.artifactstagingdirectory)

For example my YAML looks like

trigger: 
  - master

resources:
  - repo: self

variables:
  tag: '$(Build.BuildId)'

stages:
- stage: Build
  displayName: Build image
  jobs:
  - job: Build
 ...
- stage: Build
  ... define other resource/repository ...
  - task: CopyFiles@2
    inputs:
      SourceFolder: 'k8s'
      Contents: '**'
      TargetFolder: '$(build.artifactstagingdirectory)'

This pipeline is connect to a repository, which is probably defined by repo: self. So the question is, can I change this repository for a specific stage?

riQQ
  • 9,878
  • 7
  • 49
  • 66
Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333

1 Answers1

1

You can run git command in powershell script. Add a step in your stage to execute git command like below example. In this way the other repo will be cloned to artifact directory.

- powershell: |
      cd $(Build.artifactstagingdirectory)
      git clone "https://<<Your PAT>>@dev.azure.com/_organization/_project/_git/_repo"

Note: use your personal access token (PAT) as authentication.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43