diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 18d088b6efdc..1d795b6bae85 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,14 +29,22 @@ stages: image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster:latest steps: + - script: | + sourceBranch=$(Build.SourceBranchName) + if [[ "$(Build.Reason)" == "PullRequest" ]];then + sourceBranch=$(System.PullRequest.TargetBranch) + fi + echo "Download artifact branch: $sourceBranch" + echo "##vso[task.setvariable variable=sourceBranch]$sourceBranch" + displayName: "Get correct artifact downloading branch" - task: DownloadPipelineArtifact@2 inputs: source: specific project: build - pipeline: 1 + pipeline: 142 artifact: sonic-buildimage.vs runVersion: 'latestFromBranch' - runBranch: 'refs/heads/master' + runBranch: 'refs/heads/$(sourceBranch)' displayName: "Download artifacts from latest sonic-buildimage build" - script: |