From 0bd8e06050bfa4f84664725931fc52357b648386 Mon Sep 17 00:00:00 2001 From: "Martin Toman (C++ ADVANCED PROJECTS)" Date: Thu, 30 May 2024 16:00:58 +0000 Subject: [PATCH] conditional insertion of prod SC step --- .vsts.release.yml | 51 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/.vsts.release.yml b/.vsts.release.yml index fb2a4eb733..296246241d 100644 --- a/.vsts.release.yml +++ b/.vsts.release.yml @@ -206,32 +206,33 @@ extends: artifactName: agent # Upload agent packages to Azure blob storage and refresh Azure CDN - - task: AzurePowerShell@5 - displayName: Upload to Azure Blob - inputs: - azurePowerShellVersion: 'LatestVersion' - azureSubscription: 'azure-pipelines-agent-vstsagentpackage-oauth' - scriptType: 'InlineScript' - inline: | - Write-Host "Preloading Azure modules." # This is for better performance, to avoid module-autoloading. - Import-Module Azure, Az.Accounts, Az.Storage, Az.Cdn -ErrorAction Ignore -PassThru - $uploadFiles = New-Object System.Collections.ArrayList - Select-AzSubscription -SubscriptionId $(SubscriptionId) - $storageContext = New-AzStorageContext -StorageAccountName vstsagentpackage -UseConnectedAccount - $versionDir = "$(AgentVersion)" - Get-ChildItem -LiteralPath "$(System.ArtifactsDirectory)/agent" | ForEach-Object { - $target=$_ - Get-ChildItem -LiteralPath "$(System.ArtifactsDirectory)/agent/$target" -Include "*.zip","*.tar.gz" | ForEach-Object { - $executable = $_ - Write-Host "Uploading $executable to BlobStorage vstsagentpackage/agent/$versionDir" - Set-AzStorageBlobContent -Context $storageContext -Container agent -File "$(System.ArtifactsDirectory)/agent/$target/$executable" -Blob "$versionDir/$executable" -Force - $uploadFiles.Add("/agent/$versionDir/$executable") + - ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}: + - task: AzurePowerShell@5 + displayName: Upload to Azure Blob + inputs: + azurePowerShellVersion: 'LatestVersion' + azureSubscription: 'azure-pipelines-agent-vstsagentpackage-oauth' + scriptType: 'InlineScript' + inline: | + Write-Host "Preloading Azure modules." # This is for better performance, to avoid module-autoloading. + Import-Module Azure, Az.Accounts, Az.Storage, Az.Cdn -ErrorAction Ignore -PassThru + $uploadFiles = New-Object System.Collections.ArrayList + Select-AzSubscription -SubscriptionId $(SubscriptionId) + $storageContext = New-AzStorageContext -StorageAccountName vstsagentpackage -UseConnectedAccount + $versionDir = "$(AgentVersion)" + Get-ChildItem -LiteralPath "$(System.ArtifactsDirectory)/agent" | ForEach-Object { + $target=$_ + Get-ChildItem -LiteralPath "$(System.ArtifactsDirectory)/agent/$target" -Include "*.zip","*.tar.gz" | ForEach-Object { + $executable = $_ + Write-Host "Uploading $executable to BlobStorage vstsagentpackage/agent/$versionDir" + Set-AzStorageBlobContent -Context $storageContext -Container agent -File "$(System.ArtifactsDirectory)/agent/$target/$executable" -Blob "$versionDir/$executable" -Force + $uploadFiles.Add("/agent/$versionDir/$executable") + } } - } - Write-Host "Purge Azure CDN Cache" - Clear-AzCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -ContentPath $uploadFiles - Write-Host "Force Refresh Azure CDN Cache" - Import-AzCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -ContentPath $uploadFiles + Write-Host "Purge Azure CDN Cache" + Clear-AzCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -ContentPath $uploadFiles + Write-Host "Force Refresh Azure CDN Cache" + Import-AzCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -ContentPath $uploadFiles # Download all agent hashes created in previous phases - task: DownloadBuildArtifacts@0