jenkins - JenkinsFile 管道循环
问题描述
有没有人有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") {
^
...
...
...
解决方案
推荐阅读
- python - 使用 importlib 加载模块时如何允许相对导入
- r - 导入未按逻辑方式排序的数据
- javascript - 在“显示条目”中选择“全部”时的数据表,没有找到匹配的记录
- apache-spark - 当有过滤器和效率建议时,Spark 如何处理 parquet 文件
- mysql - 我很难确定哪种关系是合适的(是一对一还是一对多)
- react-native - FlatList 组件不会设置样式
- android - 如何运行 Android UI 测试并将参数传递给 App/Activity
- corda - 如何从 corda 4.3 中的开放 API 开始?
- c# - c#如何将二维数组列与字符串对齐
- java - LibGDX - 使演员水平填充父母