Jenkins Pipeline 将 String 数组传递给函数
Jenkins Pipeline pass String array to function
我使用 Jenkins 管道,我想将字符串数组传递给本地函数;我尝试使用 Strinf 可以,但不能使用 String 数组。
正在筹备中::
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'])
}
}
}
}
我使用 Jenkins 管道,我想将字符串数组传递给本地函数;我尝试使用 Strinf 可以,但不能使用 String 数组。
正在筹备中::
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'])
}
}
}
}