1
1
jobs :
2
2
- template : /.pipelines/templates/approvalJob.yml@self
3
3
parameters :
4
- displayName : Approve Blob Public
5
- jobName : ApproveBlobPublic
4
+ displayName : Approve Copy release packages to PSInfra storage
5
+ jobName : CopyReleaseBlobApproval
6
6
instructions : |
7
- Are you sure you want to make the blob public?
7
+ Approval for Copy release packages to PSInfra storage
8
8
9
- - job : blobPublic
10
- displayName : Make Azure Blob Public
11
- dependsOn : ApproveBlobPublic
12
- condition : succeeded()
9
+ - job : PSInfraReleaseBlobPublic
10
+ displayName : Copy release to PSInfra storage
11
+ dependsOn : CopyReleaseBlobApproval
13
12
pool :
14
13
type : windows
14
+
15
15
variables :
16
- - name : runCodesignValidationInjection
17
- value : false
18
- - name : NugetSecurityAnalysisWarningLevel
19
- value : none
20
- - name : DOTNET_SKIP_FIRST_TIME_EXPERIENCE
21
- value : 1
16
+ - group : ' PSInfraStorage'
22
17
- group : ' Azure Blob variable group'
23
18
- name : ob_outputDirectory
24
19
value : ' $(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
25
- - name : ob_sdl_codeSignValidation_enabled
26
- value : false
27
- - name : ob_sdl_binskim_enabled
28
- value : false
29
20
- name : ob_sdl_tsa_configFile
30
21
value : $(Build.SourcesDirectory)\PowerShell\.config\tsaoptions.json
31
22
- name : ob_sdl_credscan_suppressionsFile
@@ -34,47 +25,81 @@ jobs:
34
25
value : false
35
26
36
27
steps :
37
- - checkout : self
38
- clean : true
39
- env :
40
- ob_restore_phase : true # This ensures checkout is done at the beginning of the restore phase
28
+ - checkout : self
29
+ clean : true
30
+ env :
31
+ ob_restore_phase : true # This ensures checkout is done at the beginning of the restore phase
41
32
42
- - template : /.pipelines/templates/SetVersionVariables.yml@self
43
- parameters :
44
- ReleaseTagVar : $(ReleaseTagVar)
45
- CreateJson : yes
46
- UseJson : no
33
+ - template : /.pipelines/templates/SetVersionVariables.yml@self
34
+ parameters :
35
+ ReleaseTagVar : $(ReleaseTagVar)
36
+ CreateJson : yes
37
+ UseJson : no
47
38
48
39
- pwsh : |
49
40
Get-ChildItem Env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
50
41
displayName: 'Capture Environment Variables'
51
42
52
- - pwsh : |
53
- $azureRmModule = Get-InstalledModule AzureRM -ErrorAction SilentlyContinue -Verbose
54
- if ($azureRmModule) {
55
- Write-Host 'AzureRM module exists. Removing it'
56
- Uninstall-AzureRm
57
- Write-Host 'AzureRM module removed'
58
- }
59
-
60
- Install-Module -Name Az.Storage -Force -AllowClobber -Scope CurrentUser -Verbose
61
- displayName: Remove AzRM modules
62
-
63
- - task : AzureCLI@2
64
- displayName : ' Set blob permissions'
65
- inputs :
66
- azureSubscription : az-blob-cicd-infra
67
- scriptType : ' pscore'
68
- scriptLocation : ' inlineScript'
69
- inlineScript : |
70
- az storage container set-permission --account-name $(StorageAccount) --name $(azureVersion) --public-access blob
71
- az storage container set-permission --account-name $(StorageAccount) --name $(azureVersion)-gc --public-access blob
43
+ - pwsh: |
44
+ $azureRmModule = Get-InstalledModule AzureRM -ErrorAction SilentlyContinue -Verbose
45
+ if ($azureRmModule) {
46
+ Write-Host 'AzureRM module exists. Removing it'
47
+ Uninstall-AzureRm
48
+ Write-Host 'AzureRM module removed'
49
+ }
50
+
51
+ Install-Module -Name Az.Storage -Force -AllowClobber -Scope CurrentUser -Verbose
52
+ displayName: Remove AzRM modules
53
+
54
+ - task: AzurePowerShell@5
55
+ displayName: Copy blobs to PSInfra storage
56
+ inputs:
57
+ azureSubscription: az-blob-cicd-infra
58
+ scriptType: inlineScript
59
+ azurePowerShellVersion: LatestVersion
60
+ pwsh: true
61
+ inline: |
62
+ $sourceStorageAccountName = '$(StorageAccount)'
63
+ $destinationStorageAccountName = '$(PSInfraStorageAccount)'
64
+ $destinationContainerName = '$web'
65
+ $destinationPrefix = 'install/$(ReleaseTagVar)'
66
+
67
+ $sourceContext = New-AzStorageContext -StorageAccountName $sourceStorageAccountName
68
+ Write-Verbose -Verbose "Source context: $($sourceContext.BlobEndPoint)"
69
+
70
+ $destinationContext = New-AzStorageContext -StorageAccountName $destinationStorageAccountName
71
+ Write-Verbose -Verbose "Destination context: $($destinationContext.BlobEndPoint)"
72
+
73
+ foreach ($sourceContainerName in '$(AzureVersion)', '$(AzureVersion)-gc') {
74
+ $blobs = Get-AzStorageBlob -Context $sourceContext -Container $sourceContainerName
75
+
76
+ Write-Verbose -Verbose "Blobs found in $sourceContainerName"
77
+ $blobs.Name | Write-Verbose -Verbose
78
+
79
+ Write-Verbose -Verbose "Copying blobs from $sourceContainerName to $destinationContainerName/$destinationPrefix"
80
+
81
+ foreach ($blob in $blobs) {
82
+ $sourceBlobName = $blob.Name
83
+ Write-Verbose -Verbose "sourceBlobName = $sourceBlobName"
84
+
85
+ $destinationBlobName = "$destinationPrefix/$sourceBlobName"
86
+ Write-Verbose -Verbose "destinationBlobName = $destinationBlobName"
87
+ $existingBlob = Get-AzStorageBlob -Blob $destinationBlobName -Container $destinationContainerName -Context $destinationContext -ErrorAction Ignore
88
+ if ($existingBlob) {
89
+ Write-Verbose -Verbose "Blob $destinationBlobName already exists in '$destinationStorageAccountName/$destinationContainerName', removing before copy."
90
+ $existingBlob | Remove-AzStorageBlob -ErrorAction Stop -Verbose
91
+ }
92
+
93
+ Copy-AzStorageBlob -SourceContext $sourceContext -DestinationContext $destinationContext -SrcContainer $sourceContainerName -SrcBlob $sourceBlobName -DestContainer $destinationContainerName -DestBlob $destinationBlobName -Force -Verbose -Confirm:$false
94
+ }
95
+ }
96
+
72
97
73
98
- template : /.pipelines/templates/approvalJob.yml@self
74
99
parameters :
75
100
displayName : Approve Copy Global tool packages to PSInfra storage
76
101
jobName : CopyBlobApproval
77
- dependsOnJob : blobPublic
102
+ dependsOnJob : PSInfraReleaseBlobPublic
78
103
instructions : |
79
104
Approval for Copy global tool packages to PSInfra storage
80
105
0 commit comments