I'm trying dynamically generate stages to run them parallel, but facing next error:
WorkflowScript: 59: Expected one of "steps", "stages", or "parallel" for stage "main" @ line 59, column 5. stage('main') { ^
Here's the jenkins pipeline:
def tasks = [:]
pipeline {
agent any
stages {
stage('pre') {
steps {
script {
for (cl in env.CLUSTERS.split()) {
tasks["${cl}"] = {
stage ("${cl}") {
steps {
script {
sh (script: "./run.sh ${cl}", returnStdout: true)
}
}
}
}
}
}
}
}
stage('main') {
steps {
parallel tasks
}
}
}
}
Is there a way to fix this?
Thanks