It has to be like :
Scripted Pipeline
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'
}
}
}
}
Declarative Pipeline
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'])
}
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…