From 906cb14c0626c87dcacc904112f2aad6f80e51a8 Mon Sep 17 00:00:00 2001 From: Mike Bond Date: Wed, 5 May 2021 19:01:58 -0700 Subject: [PATCH] [CI] Use yaml-templates agent pool selector (#11356) Use release version of yaml-templates agent pool selector from main https://github.com/xamarin/yaml-templates/pull/115 --- tools/devops/automation/build-pipeline.yml | 9 ++- .../templates/agent-pool-selector.yml | 65 ------------------- .../automation/templates/build/stage.yml | 9 ++- 3 files changed, 15 insertions(+), 68 deletions(-) delete mode 100644 tools/devops/automation/templates/agent-pool-selector.yml diff --git a/tools/devops/automation/build-pipeline.yml b/tools/devops/automation/build-pipeline.yml index d9486bea86..daa8c419ef 100644 --- a/tools/devops/automation/build-pipeline.yml +++ b/tools/devops/automation/build-pipeline.yml @@ -148,7 +148,14 @@ variables: value: 'xamarin-macios' - name: PROVISIONATOR_CHANNEL value: ${{ parameters.provisionatorChannel }} - +- name: PRBuildPool + value: 'VSEng-Xamarin-RedmondMacBuildPool-iOS-Untrusted' +- name: PRBuildPoolUrl + value: 'https://devdiv.visualstudio.com/_settings/agentpools?poolId=366&view=agents' +- name: CIBuildPool + value: 'VSEng-Xamarin-RedmondMacBuildPool-iOS-Trusted' +- name: CIBuildPoolUrl + value: 'https://devdiv.visualstudio.com/_settings/agentpools?poolId=367&view=agents' trigger: branches: diff --git a/tools/devops/automation/templates/agent-pool-selector.yml b/tools/devops/automation/templates/agent-pool-selector.yml deleted file mode 100644 index 518bf7e4b3..0000000000 --- a/tools/devops/automation/templates/agent-pool-selector.yml +++ /dev/null @@ -1,65 +0,0 @@ -# -# Selects appropriate agent pool based on trigger type (PR or CI) -# -parameters: - agentPoolPR: 'VSEng-Xamarin-RedmondMacBuildPool-iOS-Untrusted' - agentPoolPRUrl: 'https://devdiv.visualstudio.com/_settings/agentpools?poolId=366&view=agents' - agentPoolCI: 'VSEng-Xamarin-RedmondMacBuildPool-iOS-Trusted' - agentPoolCIUrl: 'https://devdiv.visualstudio.com/_settings/agentpools?poolId=367&view=agents' - condition: succeeded() - -steps: - - powershell: | - $buildReason = "$(Build.Reason)" - $buildSourceBranchName = "$(Build.SourceBranchName)" - $agentPoolPR = "${{ parameters.agentPoolPR }}" - $agentPoolPRUrl = "${{ parameters.agentPoolPRUrl }}" - $agentPoolCI = "${{ parameters.agentPoolCI }}" - $agentPoolCIUrl = "${{ parameters.agentPoolCIUrl }}" - - Write-Host "buildReason: ${buildReason}" - Write-Host "buildSourceBranchName: ${buildSourceBranchName}" - Write-Host "agentPoolPR: ${agentPoolPR}" - Write-Host "agentPoolPRUrl: ${agentPoolPRUrl}" - Write-Host "agentPoolCI: ${agentPoolCI}" - Write-Host "agentPoolCIUrl: ${agentPoolCIUrl}" - - $agentPool = $agentPoolPR # Default to Catalina PR pool - $agentPoolUrl = $agentPoolPRUrl - Write-Host "Default agent pool: ${agentPool}" - - [bool] $isTopicBranch = $False - [bool] $isPullRequest = $False - - if (-not ($buildSourceBranchName -eq 'main' -or $buildSourceBranchName -eq 'master' -or $buildSourceBranchName.StartsWith('d16-'))) { - $isTopicBranch = $True - } - - if ($buildReason -eq 'PullRequest') { - $prTargetBranchName = "$(System.PullRequest.TargetBranch)" # This system variable is only defined (and in turn the value macro replaced) when $buildReason is 'PullRequest'. Consequently, it cannot be defined as part of an input parameter - Write-Host "prTargetBranchName: System.PullRequest.TargetBranch: ${prTargetBranchName}" - $isPullRequest = $True - $targetBranch = $prTargetBranchName - } else { - $targetBranch = $buildSourceBranchName - } - - Write-Host "Settings:" - Write-Host " targetBranch: ${targetBranch}" - Write-Host " isTopicBranch: ${isTopicBranch}" - Write-Host " isPullRequest: ${isPullRequest}" - - if ($isPullRequest) { - $agentPool = $agentPoolPR # Untrusted on-prem iOS pool used for all PRs (including those from forks) and feature/topic branch commits not targeting main or d16-x branches - $agentPoolUrl = $agentPoolPRUrl - } else { - $agentPool = $agentPoolCI # Trusted on-prem iOS pool used for CIs targeting main and d16-x release branches - $agentPoolUrl = $agentPoolCIUrl - } - - Write-Host "AgentPoolComputed: ${agentPool}" - Write-Host "Selected agent pool: ${agentPoolUrl}" - Write-Host "##vso[task.setvariable variable=AgentPoolComputed;isOutput=true]$agentPool" - name: setAgentPool - displayName: 'AgentPoolSelector: Select agent pool' - condition: ${{ parameters.condition }} diff --git a/tools/devops/automation/templates/build/stage.yml b/tools/devops/automation/templates/build/stage.yml index 18f24c3208..4e58ef3888 100644 --- a/tools/devops/automation/templates/build/stage.yml +++ b/tools/devops/automation/templates/build/stage.yml @@ -43,8 +43,13 @@ jobs: steps: - checkout: none # https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#checkout - # Selects appropriate agent pool based on trigger type (PR or CI) - - template: ../agent-pool-selector.yml + # Selects appropriate agent pool based on trigger type (PR or CI); manually triggered builds target the PR pool + - template: azure-devops-pools/agent-pool-selector.yml@templates + parameters: + agentPoolPR: $(PRBuildPool) + agentPoolPRUrl: $(PRBuildPoolUrl) + agentPoolCI: $(CIBuildPool) + agentPoolCIUrl: $(CIBuildPoolUrl) - job: build dependsOn: