我有一系列涉及构建和测试的阶段。我想在多个平台上并行运行这些。我无法弄清楚如何使用声明性语法来做到这一点。
根据文档parallel和示例,我试图将变量设置为阶段列表以在两个并行阶段的每一个中运行,但看起来您不能以声明方式以这种方式使用变量?
def stage_list = {
stage('hello world') {
steps {
echo "hello world"
}
}
stage('dump environment') {
steps {
echo "---- environment ----"
sh "env | sort"
}
}
}
pipeline {
agent none
stages {
stage('multi platform build') {
parallel {
stage ('Ubuntu') {
agent { label "Ubuntu" }
stages stage_list
}
stage ('CentOS') {
agent { label "CentOS" }
stages stage_list
}
}
}
}
}
看起来它没有解释变量?有没有办法做到这一点?
WorkflowScript: 22: Expected a block for stages @ line 22, column 6.
stages stage_list