Jeanluca Scaljeri
Jeanluca Scaljeri

Reputation: 29129

Change repo for 1 stage in multi-stage pipeline

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?

Upvotes: 0

Views: 166

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30313

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.

Upvotes: 1

Related Questions