@@ -6,38 +6,39 @@ 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 , spotRetryCounter ) {
10+ def platform
11+ switch (imageType) {
12+ // TODO: to be removed later, when Windows 2019 support is dropped
13+ // cf https://github.com/jenkins-infra/helpdesk/issues/4954
14+ // nanoserver-1809, nanoserver-ltsc2019 and windowservercore-ltsc2019
15+ case ~/ .*9/ :
16+ platform = ' windows-2019'
17+ break
2718
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- }
19+ // TODO: to be removed later, when using Windows 2025 agents by default
20+ // cf https://github.com/jenkins-infra/helpdesk/issues/4956
21+ // nanoserver-ltsc2022 and windowservercore-ltsc2022
22+ case ~/ .*2/ :
23+ platform = ' windows-2022'
24+ break
25+
26+ // TODO: to be replaced by ~/*server*/, when using Windows 2025 agents by default for Windows images
27+ // cf https://github.com/jenkins-infra/helpdesk/issues/4956
28+ // nanoserver-ltsc2025 and windowservercore-ltsc2025
29+ case ~/ .*5/ :
30+ platform = ' windows-2025'
31+ break
3532
36- if (counter > 1 ) {
37- return agentLabel + ' && nonspot'
33+ // Linux
34+ default :
35+ // Need Docker and a LOT of memory for faster builds (due to multi archs)
36+ platform = ' docker-highmem'
37+ break
3838 }
3939
40- return agentLabel + ' && spot'
40+ // Defined in https://github.com/jenkins-infra/pipeline-library/blob/master/vars/infra.groovy
41+ return infra. getBuildAgentLabel(platform, ' any' , false , spotRetryCounter)
4142}
4243
4344// Specify parallel stages
@@ -56,7 +57,7 @@ def parallelStages = [failFast: false]
5657 int retryCounter = 0
5758 retry(count : 2 , conditions : [agent(), nonresumable()]) {
5859 // Use local variable to manage concurrency and increment BEFORE spinning up any agent
59- final String resolvedAgentLabel = spotAgentSelector( agentSelector(imageType) , retryCounter)
60+ final String resolvedAgentLabel = agentSelector(imageType, retryCounter)
6061 retryCounter++
6162 node(resolvedAgentLabel) {
6263 timeout(time : 60 , unit : ' MINUTES' ) {
0 commit comments