groovy.lang.MissingPropertyException: No such property: manager for class: Script1

时光怂恿深爱的人放手 提交于 2019-11-30 08:17:16

Maybe I'm missing some part of your code, but where do you define the manager? If that's the complete Groovy script, you're trying to bind a variable which isn't declared anything, so it's not to weird that it fails, right?

Just define a manager it that's what you want, like:

def manager = "my manager" // probably not what you want

And should should be rid of your current error.

manager is provided by certain Groovy script plugins, but not all. To make your script generic, use the Jenkins/Hudson API instead:

import hudson.model.*

def build = Thread.currentThread().executable
def buildNumber = build.number
...

Just in case it helps, if you are using the 'Execute System Groovy Script', you don't need to use the 'manager' variable. This worked for me -

def workspace = build.getEnvVars()["WORKSPACE"]

One of the reasons groovy.lang.MissingPropertyException: is thrown when you are using a variable outside of its scope or you haven't defined that variable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!