From 88fe8bcabc17fb138e8d6e051fadb7c8f0e845fc Mon Sep 17 00:00:00 2001 From: Leilei Zhang Date: Sat, 15 Feb 2025 21:10:04 +0800 Subject: [PATCH] update --- ...teps-download-artifacts-with-azure-cli.yml | 65 ++++++++++--------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/.pipelines/v2/templates/steps-download-artifacts-with-azure-cli.yml b/.pipelines/v2/templates/steps-download-artifacts-with-azure-cli.yml index a8ea96da3d..c9fc2b733d 100644 --- a/.pipelines/v2/templates/steps-download-artifacts-with-azure-cli.yml +++ b/.pipelines/v2/templates/steps-download-artifacts-with-azure-cli.yml @@ -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) \ No newline at end of file +- 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) \ No newline at end of file