当我运行下面的Jenkins管道脚本时:
def some_var = "some value"
def pr() {
def another_var = "another " + some_var
echo "${another_var}"
}
pipeline {
agent any
stages {
stage ("Run") {
steps {
pr()
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
groovy.lang.MissingPropertyException: No such property: some_var for class: groovy.lang.Binding
Run Code Online (Sandbox Code Playgroud)
如果def
删除some_var
它,它工作正常.有人可以解释导致此行为的范围规则吗?