@@ -6,38 +6,37 @@ 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+ // nanoserver-ltsc2022 and windowservercore-ltsc2022
18+ case ~/ .*2022/ :
19+ platform = ' windows-2022'
20+ break
21+
22+ // nanoserver-ltsc2025 and windowservercore-ltsc2025
23+ case ~/ .*2025/ :
24+ platform = ' windows-2025'
25+ break
3526
36- if (counter > 1 ) {
37- return agentLabel + ' && nonspot'
27+ // Linux
28+ default :
29+ // Need Docker and a LOT of memory for faster builds (due to multi archs)
30+ platform = ' docker-highmem'
31+ break
3832 }
3933
40- return agentLabel + ' && spot'
34+ // Defined in https://github.com/jenkins-infra/pipeline-library/blob/master/vars/infra.groovy
35+ return infra. getBuildAgentLabel([
36+ useContainerAgent : false ,
37+ platform : platform,
38+ spotRetryCounter : retryCounter
39+ ])
4140}
4241
4342// Specify parallel stages
@@ -56,7 +55,7 @@ def parallelStages = [failFast: false]
5655 int retryCounter = 0
5756 retry(count : 2 , conditions : [agent(), nonresumable()]) {
5857 // Use local variable to manage concurrency and increment BEFORE spinning up any agent
59- final String resolvedAgentLabel = spotAgentSelector( agentSelector(imageType) , retryCounter)
58+ final String resolvedAgentLabel = agentSelector(imageType, retryCounter)
6059 retryCounter++
6160 node(resolvedAgentLabel) {
6261 timeout(time : 60 , unit : ' MINUTES' ) {
0 commit comments