This commit is contained in:
Leilei Zhang
2025-02-15 21:10:04 +08:00
parent 5e00741e6a
commit 88fe8bcabc

View File

@@ -1,43 +1,46 @@
parameters:
- name: artifactName
type: string
default: ""
- name: downloadPath
type: string
default: ''
- name: downloadRunId
type: string
default: ''
- name: artifactName
type: string
default: ""
- name: downloadPath
type: string
default: ''
- name: downloadRunId
type: string
default: ''
variables:
AzureCliDir: '$(Build.ArtifactStagingDirectory)\AzureCLI'
AzureCliPath: '$(AzureCLIDir)\bin'
AzureCli: '$(AzCliPath)\az.cmd'
- name: AzureCliDir
value: '$(Build.ArtifactStagingDirectory)\AzureCLI'
- name: AzureCliPath
value: '$(AzureCliDir)\bin'
- name: AzureCli
value: '$(AzCliPath)\az.cmd'
# Why use az cli to download? → The ARM agent may run into OutOfMemory issues.
# Why use the Azure CLI ZIP version? → It comes with its own Python and works fine under emulation on ARM64.
# Why not use AzureCLI@2 task? → It requires azureSubscription, which is unnecessary for downloading artifacts.
steps:
- powershell: |
Write-Host "Downloading Azure CLI ZIP..."
$azCliUrl = "https://azcliprod.blob.core.windows.net/zip/azure-cli-2.69.0-x64.zip"
$azCliZip = "$(Build.ArtifactStagingDirectory)\azure-cli-2.69.0-x64.zip"
- powershell: |
Write-Host "Downloading Azure CLI ZIP..."
$azCliUrl = "https://azcliprod.blob.core.windows.net/zip/azure-cli-2.69.0-x64.zip"
$azCliZip = "$(Build.ArtifactStagingDirectory)\azure-cli-2.69.0-x64.zip"
Invoke-WebRequest -Uri $azCliUrl -OutFile $azCliZip
displayName: 'Install Azure CLI from ZIP'
Invoke-WebRequest -Uri $azCliUrl -OutFile $azCliZip
displayName: 'Install Azure CLI from ZIP'
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(Build.ArtifactStagingDirectory)\azure-cli-2.69.0-x64.zip'
destinationFolder: '${{variables.AzureCliDir}}'
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(Build.ArtifactStagingDirectory)\azure-cli-2.69.0-x64.zip'
destinationFolder: '${{variables.AzureCliDir}}'
- pwsh: |
$azCliPath = "${{variables.AzureCliPath}}"
Write-Host "Configuring Azure DevOps defaults..."
& "$azCliPath\az.cmd" devops configure --defaults organization='$(System.TeamFoundationCollectionUri)' project='$(System.TeamProject)' --use-git-aliases true
Write-Host "Downloading artifacts..."
& "$azCliPath\az.cmd"z pipelines runs artifact download --artifact-name ${{parameters.artifactName}} --path "${{parameters.downloadPath}}" --run-id ${{parameters.downloadRunId}} --debug
displayName: 'Download artifacts with Azure CLI'
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
- pwsh: |
$azCliPath = "${{variables.AzureCliPath}}"
Write-Host "Configuring Azure DevOps defaults..."
& "$azCliPath\az.cmd" devops configure --defaults organization='$(System.TeamFoundationCollectionUri)' project='$(System.TeamProject)' --use-git-aliases true
Write-Host "Downloading artifacts..."
& "$azCliPath\az.cmd" pipelines runs artifact download --artifact-name ${{parameters.artifactName}} --path "${{parameters.downloadPath}}" --run-id ${{parameters.downloadRunId}} --debug
displayName: 'Download artifacts with Azure CLI'
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)