I am working on declarative pipeline. I am trying to achieve dynamic stages which should distribute the stages parallel with the agents defined. When i explored i learned how to achieve Dynamic sequential stages. Below is my sample code.
My problem now is, how to achieve parallel stages with agents i have. For example, if i have 3 agents all the 5 stages should run parallel in the agents parallel. I tried using parallel tests but not working. Please help me to improve further !
def learn
pipeline {
agent none
stages {
stage('Dynamic Stages') {
steps {
script {
learn = ["1", "2", "3", "4", "5"]
for(int i=0; i < list.size(); i++) {
stage(list[i]){
echo "value: $i"
}
}
}
}
}
}
}