| jobs: |
| - job: DeleteBlob |
| variables: |
| - group: Azure Blob variable group |
| - group: AzureBlobServiceConnection |
| - name: ob_artifactBaseName |
| value: BuildInfoJson |
| - name: ob_outputDirectory |
| value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT/BuildJson' |
| - name: ob_sdl_sbom_enabled |
| value: false |
| - name: ob_sdl_codeSignValidation_enabled |
| value: false |
| - name: ob_sdl_tsa_configFile |
| value: $(Build.SourcesDirectory)\PowerShell\.config\tsaoptions.json |
| - name: ob_sdl_credscan_suppressionsFile |
| value: $(Build.SourcesDirectory)\PowerShell\.config\suppress.json |
| - name: ob_sdl_codeql_compiled_enabled |
| value: false |
|
|
| displayName: Delete blob is exists |
| pool: |
| type: windows |
| steps: |
| - checkout: self |
| clean: true |
| env: |
| ob_restore_phase: true |
|
|
| - template: /.pipelines/templates/SetVersionVariables.yml@self |
| parameters: |
| ReleaseTagVar: $(ReleaseTagVar) |
| CreateJson: yes |
|
|
| - template: /.pipelines/templates/cloneToOfficialPath.yml@self |
|
|
| - template: /.pipelines/templates/insert-nuget-config-azfeed.yml@self |
| parameters: |
| repoRoot: $(PowerShellRoot) |
|
|
| - pwsh: | |
| if (-not (Test-Path -Path $(Build.SourcesDirectory)\PowerShell\.config\tsaoptions.json)) { |
| Get-ChildItem -Path $(Build.SourcesDirectory) -Recurse |
| throw 'tsaoptions.json not found' |
| } |
| displayName: 'Check tsaoptions.json' |
|
|
| - pwsh: | |
| if (-not (Test-Path -Path $(Build.SourcesDirectory)\PowerShell\.config\suppress.json)) { |
| Get-ChildItem -Path $(Build.SourcesDirectory) -Recurse |
| throw 'suppress.json not found' |
| } |
| displayName: 'Check suppress.json' |
|
|
| - task: AzurePowerShell@5 |
| displayName: Check if blob exists and delete if specified |
| inputs: |
| azureSubscription: az-blob-cicd-infra |
| scriptType: inlineScript |
| azurePowerShellVersion: LatestVersion |
| pwsh: true |
| inline: | |
| $containersToDelete = @('$(AzureVersion)', '$(AzureVersion)-private', '$(AzureVersion)-nuget', '$(AzureVersion)-gc') |
| |
| $containersToDelete | ForEach-Object { |
| $containerName = $_ |
| try { |
| $container = Get-AzStorageContainer -Container $containerName -Context (New-AzStorageContext -StorageAccountName '$(StorageAccount)') -ErrorAction Stop |
| if ($container -ne $null -and '$(ForceAzureBlobDelete)' -eq 'false') { |
| throw "Azure blob container $containerName already exists. To overwrite, use ForceAzureBlobDelete parameter" |
| } |
| elseif ($container -ne $null -and '$(ForceAzureBlobDelete)' -eq 'true') { |
| Write-Verbose -Verbose "Removing container $containerName due to ForceAzureBlobDelete parameter" |
| Remove-AzStorageContainer -Name $containerName -Context (New-AzStorageContext -StorageAccountName '$(StorageAccount)') -Force |
| } |
| } |
| catch { |
| if ($_.FullyQualifiedErrorId -eq 'ResourceNotFoundException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageContainerCommand') { |
| Write-Verbose -Verbose "Container $containerName does not exists." |
| } |
| else { |
| throw $_ |
| } |
| } |
| } |
| - template: /.pipelines/templates/step/finalize.yml@self |
|
|