我正在尝试创建一个声明式的Jenkins管道脚本,但在简单变量声明方面遇到问题。
这是我的脚本:
pipeline {
agent none
stages {
stage("first") {
def foo = "foo" // fails with "WorkflowScript: 5: Expected a step @ line 5, column 13."
sh "echo ${foo}"
}
}
}
然而,我遇到了这个错误:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 5: Expected a step @ line 5, column 13.
def foo = "foo"
^
我使用的是 Jenkins 2.7.4 和 Pipeline 2.4.