@@ -6,38 +6,32 @@ properties([
66 pipelineTriggers([cron(cronExpr)]),
77])
88
9- def agentSelector (String imageType ) {
10- // Linux agent
11- if (imageType == ' linux' ) {
12- // This function is defined in the jenkins-infra/pipeline-library
13- if (infra. isTrusted()) {
14- return ' linux'
15- } else {
16- // Need Docker and a LOT of memory for faster builds (due to multi archs) or fallback to linux (trusted.ci)
17- return ' docker-highmem'
18- }
19- }
20- // Windows Server Core 2022 agent
21- if (imageType. contains(' 2022' )) {
22- return ' windows-2022'
23- }
24- // Windows Server Core 2019 agent (for nanoserver 1809 & ltsc2019 and for windowservercore ltsc2019)
25- return ' windows-2019'
26- }
9+ def agentSelector (String imageType , retryCounter ) {
10+ def platform
11+ switch (imageType) {
12+ // nanoserver-1809, nanoserver-ltsc2019 and windowservercore-ltsc2019
13+ case ~/ .*(1809|2019)/ :
14+ platform = ' windows-2019'
15+ break
2716
28- // Ref. https://github.com/jenkins-infra/pipeline-library/pull/917
29- def spotAgentSelector (String agentLabel , int counter ) {
30- // This function is defined in the jenkins-infra/pipeline-library
31- if (infra. isTrusted()) {
32- // Return early if on trusted (no spot agent)
33- return agentLabel
34- }
17+ // All other Windows images
18+ case ~/ (nanoserver|windowsservercore).*/ :
19+ platform = ' windows-2025'
20+ break
3521
36- if (counter > 1 ) {
37- return agentLabel + ' && nonspot'
22+ // Linux
23+ default :
24+ // Need Docker and a LOT of memory for faster builds (due to multi archs)
25+ platform = ' docker-highmem'
26+ break
3827 }
3928
40- return agentLabel + ' && spot'
29+ // Defined in https://github.com/jenkins-infra/pipeline-library/blob/master/vars/infra.groovy
30+ return infra. getBuildAgentLabel([
31+ useContainerAgent : false ,
32+ platform : platform,
33+ spotRetryCounter : retryCounter
34+ ])
4135}
4236
4337// Specify parallel stages
@@ -59,7 +53,7 @@ def parallelStages = [failFast: false]
5953 int retryCounter = 0
6054 retry(count : 2 , conditions : [agent(), nonresumable()]) {
6155 // Use local variable to manage concurrency and increment BEFORE spinning up any agent
62- final String resolvedAgentLabel = spotAgentSelector( agentSelector(imageType) , retryCounter)
56+ final String resolvedAgentLabel = agentSelector(imageType, retryCounter)
6357 retryCounter++
6458 node(resolvedAgentLabel) {
6559 timeout(time : 60 , unit : ' MINUTES' ) {
0 commit comments