Skip to content

Commit fa3ea3f

Browse files
authored
Replace PAT with WIF service connection in mirror pipeline (#2424)
Remove DotNet-VSTS-Infra-Access variable group and replace dn-bot-devdiv-build-rw-code-rw PAT with a WIF service connection (PerfView-Mirror-WIF) that mints AzDO bearer tokens via AzureCLI@2. The service connection needs to be created and its SP enrolled in the devdiv org with Contribute permission on DevDiv/_git/perfView.
1 parent e0f49b0 commit fa3ea3f

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

.pipelines/mirror.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
trigger:
22
- main
33

4-
variables:
5-
- group: 'DotNet-VSTS-Infra-Access'
6-
74
resources:
85
repositories:
96
- repository: 1esPipelines
@@ -29,6 +26,19 @@ extends:
2926
jobs:
3027
- job: Mirror
3128
steps:
29+
- task: AzureCLI@2
30+
displayName: 'Mint AzDO token via WIF'
31+
inputs:
32+
azureSubscription: 'DncEng Insertion: Roslyn and Razor'
33+
scriptType: 'pscore'
34+
scriptLocation: 'inlineScript'
35+
inlineScript: |
36+
$token = az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query accessToken -o tsv
37+
if ($LASTEXITCODE -ne 0) { Write-Error "Failed to get access token"; exit 1 }
38+
$token = $token.Trim()
39+
if ([string]::IsNullOrWhiteSpace($token)) { Write-Error "Token is empty"; exit 1 }
40+
Write-Host "##vso[task.setvariable variable=AzdoToken;issecret=true]$token"
41+
3242
- task: PowerShell@1
3343
displayName: 'Set SourceBranch Variable'
3444
inputs:
@@ -108,18 +118,18 @@ extends:
108118
- task: CmdLine@2
109119
displayName: 'Pull AzDO SourceBranch'
110120
inputs:
111-
script: 'git pull --strategy=recursive --strategy-option no-renames https://dn-bot:$(dn-bot-devdiv-build-rw-code-rw)@devdiv.visualstudio.com/DevDiv/_git/perfView $(SourceBranch)'
121+
script: 'git pull --strategy=recursive --strategy-option no-renames https://x-access-token:$(AzdoToken)@devdiv.visualstudio.com/DevDiv/_git/perfView $(SourceBranch)'
112122

113123
- task: CmdLine@2
114124
displayName: 'Run git push'
115125
inputs:
116-
script: 'git push https://dn-bot:$(dn-bot-devdiv-build-rw-code-rw)@devdiv.visualstudio.com/DevDiv/_git/perfView $(MirrorBranch)'
126+
script: 'git push https://x-access-token:$(AzdoToken)@devdiv.visualstudio.com/DevDiv/_git/perfView $(MirrorBranch)'
117127

118128
- task: PowerShell@1
119129
displayName: 'Create Pull Request'
120130
inputs:
121131
scriptType: inlineScript
122-
arguments: '$(dn-bot-devdiv-build-rw-code-rw)'
132+
arguments: '$(AzdoToken)'
123133
inlineScript: |
124134
param(
125135
[string]$AccessToken

0 commit comments

Comments
 (0)