Jenkins Problem with generation and launching stages in parallel

  Kiến thức lập trình

What am I doing wrong?
Sequential launch works, Parallel launch breaks with the error:

....
java.lang.IllegalArgumentException: Expected named arguments but got org.jenkinsci.plugins.workflow.cps.CpsClosure2@21710cb6
def map = [
        Gosha  : 45,
        Gera : 15,
        Serega  : 33
]
def stages_to_run = {
    map.each { key, value ->      
        stage("phase_${key}") {
            echo "name: 'Name', value: ${key}"
            echo "name: 'Age', value: ${value}"
        }
    }
}
pipeline {
    agent any
    stages {
        stage('loop') {
            steps {
                script {
                    // stages_to_run() it works
                    parallel stages_to_run() // it does not work
                }
            }
        }
    }
}

I guess I lack understanding of groovy

New contributor

Igor Nazarov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT