I have this piece of the pipeline
def list
pipeline {
agent {label 'it'}
options {buildDiscarder(logRotator(daysToKeepStr: '7', numToKeepStr: '1'))}
stages {
stage('Create List') {
steps {
script {
// you may create your list here, lets say reading from a file after checkout
list = ["Test-1", "Test-2", "Test-3", "Test-4", "Test-5"]
}
}
post {
cleanup {
cleanWs()
}
}
}
stage('Dynamic Stages') {
steps {
script {
for(int i=0; i < list.size(); i++) {
stage(list[i]){
echo "Element: $i"
}
}
}
}
post {
cleanup {
cleanWs()
}
}
}
}
}
And this shows, however, if we select stage name “Test-4”, its not allowing us to restart, only “Dynamic Stage” has option for restart. Is there any way to enable “Restart” ?
Same goes with this similar where below shows ability to dynamically create stages however option to. “Restart” dynamically created stages is not enabled. Appreciate if there is any other ideas?
stage ('Create Model Stages dynamically...'){
steps {
script {
def build_properties = readProperties file: "file.txt"
build_properties.each{ k,v ->
image_properties[k]=v
stage ("Validate Model - ${k}") {
println "${v}"
}
}
}
}
}