有人有一个带有循环的pipeline{}
示例吗?
我试图通过使用循环在多个主机上运行相同的逻辑来“压缩”一个冗长且重复的JenkinsFile。
...但是,但是...我的piepline{}
JenkinsFile中没有循环。
具体来说,我正在这样做...
pipeline {
agent { label 'buildhost' }
stages {
stage("checks") {
parallel {
// ['mac-amd64', 'linux-arm', 'win-amd64', 'linux-x86', 'linux-armv8', 'linux-amd64' ].each {
['mac-amd64', 'linux-armv8', 'linux-amd64'].each {
host ->
stage("checks / ${host}") {
agent { label "buildhost-${host}" }
steps {
dir ('peterlavalle.sbt/') {
// combining these seemed to launch the SBT server which makes Jenkins hang
sh 'java -Dsbt.log.noformat=true -jar ./sbt-launch.jar clean'
sh 'java -Dsbt.log.noformat=true -jar ./sbt-launch.jar test'
sh 'java -Dsbt.log.noformat=true -jar ./sbt-launch.jar publish'
}
['cgc3.gradle/', 'kanobi.sbt/'].each {
gradle ->
dir (path) {
sh 'chmod +=rwx ./gradlew'
sh './gradlew --stacktrace --console=plain clean'
sh './gradlew --stacktrace --console=plain check'
sh './gradlew --stacktrace --console=plain publish'
}
}
dir ("coffeeskript.cgc/") {
sh 'chmod +=rwx ./gradlew'
sh './gradlew --stacktrace --console=plain check'
}
}
}
}
}
}
}
}
}
...,詹金斯说:“只有阶段!”或类似的东西。
...
...
...
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 47: Expected a stage @ line 47, column 11.
['mac-amd64', 'linux-armv8', 'linux-amd64'].each {
^
WorkflowScript: 44: Expected one of "steps", "stages", or "parallel" for stage "checks" @ line 44, column 4.
stage("checks") {
^
...
...
...