Let's start solving this by assuming that we have configured the hosts to Jenkins master as Jenkins slaves, and also make sure that hosts are provided in the pipeline job parameter.
Make HOSTS as a separated list. Go through the code
def hosts_pairs = HOSTS.split().collate(2)
for (pair in host_pairs) {
def branches = [:]
for (h in pair) {
def host = h // new variable for every iteration; it will be mutated
branches[host] = {
stage(host) {
node(host) {
// here we mention the actual job,e.g.
sh "echo hello world"
}
}
}
}
parallel branches
}
The above code will help you to understand what are the classes/methods in the dsl-groovy code.