Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional insertion of step that uses prod SC #4824

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions .vsts.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading