Skip to content

Commit

Permalink
[release/8.0.1xx-xcode15.4] Disable/reenable agents using dynamically…
Browse files Browse the repository at this point in the history
… obtained access token (#21224)

Replace `MacPoolAccessToken` with a dynamically obtained Azure DevOps
access token. The `MacPoolAccessToken` is backed by the
`botdeploy--azdo--token--register--untrusted` secret, which is limited
to a 7-day lifespan. This change removes the dependency on that token


Backport of #21216

---------

Co-authored-by: Mike Bond <mjbond-msft@outlook.com>
  • Loading branch information
1 parent a62f4c9 commit 7a29434
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
2 changes: 0 additions & 2 deletions tools/devops/automation/templates/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ variables:
value: true
- name: BUILD_REVISION
value: azure-devops-$(Build.SourceVersion)
- name: MacPoolAccessToken
value: $(botdeploy--azdo--token--register--untrusted)
25 changes: 25 additions & 0 deletions tools/devops/automation/templates/windows/generate-token.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Sets the AzDO.BearerToken variable that can be used as the auth token to disable/reenable agents
steps:
- template: azure-tools/az-client-update.yml@yaml-templates # AzureCLI step below requires that AzClient 2.x is installed on the agent
parameters:
platform: 'All' # Update Az tools for both Windows and Mac agents
version: '2.62.0'

# https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/1es-security-configuration/configuration-guides/pat-burndown-guidance#authentication-from-pipelines
# Requires Azure client 2.x
- task: AzureCLI@2
displayName: 'AzDO.BearerToken based on service connection'
enabled: true
inputs:
azureSubscription: 'DevDiv - SharedUntrustedAgentPool-Manage'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
# if this fails, check out this bash script that includes diagnostics:
# https://gist.github.com/johnterickson/19f80a3e969e39f1000d118739176e62
# Note that the resource is specified to limit the token to Azure DevOps
$token = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
Write-Host "Setting AzDO.BearerToken"
Write-Host "##vso[task.setvariable variable=AzDO.BearerToken;issecret=true]${token}"
10 changes: 9 additions & 1 deletion tools/devops/automation/templates/windows/reenable-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ steps:
condition: always()
continueOnError: true

# Sets the AzDO.BearerToken variable used as the auth token to disable/reenable agents
- template: ./generate-token.yml

- pwsh: |
Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\MaciosCI.psd1
$vsts = New-VSTS -Org "devdiv" -Project "DevDiv" -Token $(MacPoolAccessToken)
$azdoBearerToken = "$(AzDO.BearerToken)"
$azdoBearerTokenHint = $azdoBearerToken.Substring(0, 8)
Write-Host "AzDO.BearerToken (hint): ${azdoBearerTokenHint}"
$vsts = New-VSTS -Org "devdiv" -Project "DevDiv" -Token $azdoBearerToken
# get the pool and the agent objects and enable the bot
$pool = $vsts.Pools.GetPool("$Env:MAC_AGENT_POOL")
Expand Down
9 changes: 8 additions & 1 deletion tools/devops/automation/templates/windows/reserve-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ steps:
AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_P12: ${{ parameters.xqaCertPass }}
AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_2_P12: ${{ parameters.xqaCertPass }}

# Sets the AzDO.BearerToken variable used as the auth token to disable/reenable agents
- template: ./generate-token.yml

- pwsh: |
Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\MaciosCI.psd1
New-Item -Path "$($Env:HOME)" -Name "remote_build_testing" -Force -ItemType "directory"
New-Item -Path "$($Env:HOME)/remote_build_testing" -Name "BuildId.txt" -ItemType "file" -Force -Value "$($Env:BUILD_BUILDID)"
$vsts = New-VSTS -Org "devdiv" -Project "DevDiv" -Token $(MacPoolAccessToken)
$azdoBearerToken = "$(AzDO.BearerToken)"
$azdoBearerTokenHint = $azdoBearerToken.Substring(0, 8)
Write-Host "AzDO.BearerToken (hint): ${azdoBearerTokenHint}"
$vsts = New-VSTS -Org "devdiv" -Project "DevDiv" -Token $azdoBearerToken
# get the pool and the agent objects and disable the bot
$pool = $vsts.Pools.GetPool("${{ parameters.macPool }}")
Expand Down

14 comments on commit 7a29434

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Big Sur (11) failed ❌

Tests on macOS M1 - Mac Big Sur (11) failed for unknown reasons.

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Monterey (12) failed ❌

Tests on macOS M1 - Mac Monterey (12) failed for unknown reasons.

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Ventura (13) failed ❌

Tests on macOS M1 - Mac Ventura (13) failed for unknown reasons.

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Big Sur (11) failed ❌

Tests on macOS M1 - Mac Big Sur (11) failed for unknown reasons.

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Ventura (13) failed ❌

Tests on macOS M1 - Mac Ventura (13) failed for unknown reasons.

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Monterey (12) failed ❌

Tests on macOS M1 - Mac Monterey (12) failed for unknown reasons.

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS X64 - Mac Sonoma (14) failed ❌

Tests on macOS X64 - Mac Sonoma (14) failed for unknown reasons.

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS X64 - Mac Sonoma (14) failed ❌

Tests on macOS X64 - Mac Sonoma (14) failed for unknown reasons.

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Artifacts were not provided.

Pipeline on Agent
Hash: [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ API diff for current PR / commit

NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

.NET (No breaking changes)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 98 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ install-source: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
⚠️ mac-binding-project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ monotouch (iOS): All 7 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 7 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 7 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

1 tests crashed, 0 tests failed, 58 tests passed.

Failures

❌ linker tests

🔥 Failed catastrophically on VSTS: test results - linker (no summary found).

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ install-source: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
⚠️ mac-binding-project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ monotouch (iOS): All 7 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 7 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 7 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Windows Integration Tests failed ❌

❌ Failed ❌

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Windows Integration Tests failed ❌

❌ Failed ❌

Pipeline on Agent
Hash: 7a294346023525f5e003e1c677491234580a387d [CI build]

Please sign in to comment.