I'm running a Jenkins Job on multiple platforms selected manually at runtime. Having multi-select Active Choices Parameter named "Platforms" for the relevant nodes.
I'm using the following code in Jenkins scripted pipeline:
def labels=Platforms.toString().split(",").collect{"\'" + it + "\'"}
def builders=[:]
for (label in labels) {
builders[label] = {
node(label) {
stage ('Stage 1') {
sh 'hostname'
}
}
}
}
parallel builders
How can I accomplish the same thing in Declarative Pipeline? The agents are selected randomly by the user at runtime.
Thanks.