Skip to content

Commit 5732687

Browse files
committed
change how to auth with cargo feed
1 parent 01014b9 commit 5732687

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

.pipelines/DSC-Official.yml

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,20 @@ extends:
101101
displayName: BuildWin
102102
steps:
103103
- checkout: self
104-
env:
104+
env:
105105
ob_restore_phase: true
106106
- task: CodeQL3000Init@0 # Add CodeQL Init task right before your 'Build' step.
107107
inputs:
108108
Enabled: true
109109
AnalyzeInPipeline: true
110110
Language: rust
111-
env:
111+
env:
112112
ob_restore_phase: true
113113
- pwsh: |
114114
$tmpdir = "$(Agent.TempDirectory)"
115115
Write-Host "##vso[task.setvariable variable=CARGO_TARGET_DIR;]$tmpdir"
116116
displayName: 🛠️ Workaround for the LoadLibrary ACCESS_VIOLATION OneBranch issue
117-
env:
117+
env:
118118
ob_restore_phase: true
119119
- task: RustInstaller@1
120120
inputs:
@@ -123,14 +123,14 @@ extends:
123123
cratesIoFeedOverride: sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/
124124
additionalTargets: $(buildName)
125125
displayName: Install Rust
126-
env:
126+
env:
127127
ob_restore_phase: true
128128
- task: CargoAuthenticate@0
129129
inputs:
130130
configFile: "$(Build.SourcesDirectory)/DSC/.cargo/config.toml"
131131
cargoServiceConnections: azDO-Cargo-PowerShell-feed-Ingestion
132132
displayName: Authenticating cargo crates registry
133-
env:
133+
env:
134134
ob_restore_phase: true
135135
- pwsh: |
136136
Set-Location "$(Build.SourcesDirectory)/DSC"
@@ -139,12 +139,12 @@ extends:
139139
Add-Content -Path "./.cargo/config.toml" -Value 'replace-with = "powershell"'
140140
./build.ps1 -Release -Architecture $(buildName) -SkipLinkCheck
141141
displayName: 'Build $(buildName)'
142-
env:
142+
env:
143143
ob_restore_phase: true
144144
condition: succeeded()
145145
- task: CodeQL3000Finalize@0 # Add CodeQL Finalize task right after your 'Build' step.
146146
condition: always()
147-
env:
147+
env:
148148
ob_restore_phase: true
149149
- pwsh: |
150150
$null = New-Item -ItemType Directory -Path "$(PackageRoot)" -ErrorAction Ignore
@@ -159,7 +159,7 @@ extends:
159159
write-host 'Binaries in $(signSrcPath)'
160160
dir -r "$(signSrcPath)"
161161
displayName: Copy built binaries
162-
env:
162+
env:
163163
ob_restore_phase: true
164164
condition: succeeded()
165165
- task: onebranch.pipeline.signing@1
@@ -249,14 +249,22 @@ extends:
249249
cratesIoFeedOverride: sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/
250250
additionalTargets: x86_64-unknown-linux-gnu
251251
displayName: Install Rust
252-
env:
252+
env:
253253
ob_restore_phase: true
254-
- task: CargoAuthenticate@0
254+
- task: AzureCLI@2
255255
inputs:
256-
configFile: ".cargo/config.toml"
257-
cargoServiceConnections: azDO-Cargo-PowerShell-feed-Ingestion
258-
displayName: Authenticating cargo crates registry
259-
env:
256+
azureSubscription: az-PowerShell-feed-ingestion
257+
scriptType: 'pscore'
258+
scriptLocation: 'inlineScript'
259+
inlineScript: |
260+
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
261+
262+
# Set the access token as a secret, so it doesn't get leaked in the logs
263+
Write-Host "##vso[task.setsecret]$accessToken"
264+
$header = Bearer $accessToken
265+
Write-Host "##vso[task.setvariable variable=CARGO_REGISTRIES_POWERSHELL_TOKEN;issecret=true]$header"
266+
displayName: 'Get Azure DevOps Token'
267+
env:
260268
ob_restore_phase: true
261269
- pwsh: |
262270
Write-Host "Use 'powershell' CFS"
@@ -285,14 +293,22 @@ extends:
285293
cratesIoFeedOverride: sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/
286294
additionalTargets: aarch64-unknown-linux-gnu
287295
displayName: Install Rust
288-
env:
296+
env:
289297
ob_restore_phase: true
290-
- task: CargoAuthenticate@0
298+
- task: AzureCLI@2
291299
inputs:
292-
configFile: ".cargo/config.toml"
293-
cargoServiceConnections: azDO-Cargo-PowerShell-feed-Ingestion
294-
displayName: Authenticating cargo crates registry
295-
env:
300+
azureSubscription: az-PowerShell-feed-ingestion
301+
scriptType: 'pscore'
302+
scriptLocation: 'inlineScript'
303+
inlineScript: |
304+
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
305+
306+
# Set the access token as a secret, so it doesn't get leaked in the logs
307+
Write-Host "##vso[task.setsecret]$accessToken"
308+
$header = Bearer $accessToken
309+
Write-Host "##vso[task.setvariable variable=CARGO_REGISTRIES_POWERSHELL_TOKEN;issecret=true]$header"
310+
displayName: 'Get Azure DevOps Token'
311+
env:
296312
ob_restore_phase: true
297313
- pwsh: |
298314
Write-Host "Use 'powershell' CFS"
@@ -329,14 +345,14 @@ extends:
329345
cratesIoFeedOverride: sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/
330346
additionalTargets: $(buildName)
331347
displayName: Install Rust
332-
env:
348+
env:
333349
ob_restore_phase: true
334350
- task: CargoAuthenticate@0
335351
inputs:
336352
configFile: ".cargo/config.toml"
337353
cargoServiceConnections: azDO-Cargo-PowerShell-feed-Ingestion
338354
displayName: Authenticating cargo crates registry
339-
env:
355+
env:
340356
ob_restore_phase: true
341357
- pwsh: |
342358
Write-Host "Use 'powershell' CFS"

0 commit comments

Comments
 (0)