Jenkins管道将字符串数组传递给函数

Jenkins管道将字符串数组传递给函数,jenkins,groovy,jenkins-pipeline,Jenkins,Groovy,Jenkins Pipeline,我使用Jenkins管道,希望将字符串数组传递给本地函数;我尝试使用Strinf可以,但不能使用字符串数组 正在进行中:: stage('package') { steps { executeModuleScripts(["module1", "module2"]) } } 在管道末端: void executeModuleScripts(allModules) { allModules.each { modul

我使用Jenkins管道,希望将字符串数组传递给本地函数;我尝试使用Strinf可以,但不能使用字符串数组

正在进行中:

stage('package') {
    steps {
        executeModuleScripts(["module1", "module2"])
    }
}
在管道末端:

void executeModuleScripts(allModules) {

    allModules.each { module ->
    
        String gitFolder = "${module}"
          
        script {
            stage(module) {
                bat 'xcopy "' + gitFolder + '/foo/*" "temp/PUB/foo" /C /S /I /F /H'
            }
        }

    }   
}
我有一个错误:

groovy.lang.MissingPropertyException: No such property: operation for class: groovy.lang.Binding
它必须是这样的:

脚本化管道

node {
    stage('package') {
        executeModuleScripts(['01','02'])
    }
}
void executeModuleScripts(allModules) {
    allModules.each { module ->
        script {
            stage(module) {
                // sh "cp -R ${module}/foo/* temp/PUB/foo"
                bat 'xcopy "' + module + '/foo/*" "temp/PUB/foo" /C /S /I /F /H'
            }
        }

    }   
}
void executeModuleScripts(allModules) {
    allModules.each { module ->
        script {
            stage(module) {
                // sh "cp -R ${module}/foo/* temp/PUB/foo"
                bat 'xcopy "' + module + '/foo/*" "temp/PUB/foo" /C /S /I /F /H'
            }
        }

    }   
}

pipeline {
    agent any;
    stages {
        stage('package') {
            steps {
                executeModuleScripts(['A','B'])
            }
        }
    }
}
声明性管道

node {
    stage('package') {
        executeModuleScripts(['01','02'])
    }
}
void executeModuleScripts(allModules) {
    allModules.each { module ->
        script {
            stage(module) {
                // sh "cp -R ${module}/foo/* temp/PUB/foo"
                bat 'xcopy "' + module + '/foo/*" "temp/PUB/foo" /C /S /I /F /H'
            }
        }

    }   
}
void executeModuleScripts(allModules) {
    allModules.each { module ->
        script {
            stage(module) {
                // sh "cp -R ${module}/foo/* temp/PUB/foo"
                bat 'xcopy "' + module + '/foo/*" "temp/PUB/foo" /C /S /I /F /H'
            }
        }

    }   
}

pipeline {
    agent any;
    stages {
        stage('package') {
            steps {
                executeModuleScripts(['A','B'])
            }
        }
    }
}