groovy.lang.MissingPropertyException:没有这样的属性:类的经理:Script1 [英] groovy.lang.MissingPropertyException: No such property: manager for class: Script1
问题描述
我试图在Hudson中调用Groovy(使用groovy插件)来获得我们构建的一些属性。但是我得到这个异常:
groovy.lang.MissingPropertyException:没有这样的属性:类的经理:Script1
def buildNUmber = manager.build.number
这种情况发生在我作为Jenkins内联命令运行以及使用脚本时:
我尝试了下面的解决方案,但是在声明本身(第二行)时失败:
绑定绑定=新捆绑();
binding.setVariable(manager,manager);
GroovyShell shell = new GroovyShell(binding);
shell.evaluate(新文件(d:/dev/others/hudson/userContent/ScriptStuff.groovy)。text);
以上是使用Groovy命令运行的。当我运行构建它的错误和抱怨行 - binding.setVariable(manager,manager);
当我使用Groovy脚本文件时,它会抱怨:
def buildNumber = manager.build.number
这两个错误都是:groovy.lang.MissingPropertyException:没有这样的属性:class:Script1的管理器
尝试了 thread 以及:
我使用Hudson 2.2.1和Groovy 2.1.3。有什么可能是错误的?可能我错过了代码的一部分,但是你在哪里定义了管理器?如果这是完整的Groovy脚本,你试图绑定一个没有声明任何东西的变量,所以它不会奇怪它会失败,对吧?
只需定义一个经理,它就是你想要的,比如:
def manager =我的经理//可能不是你想要的
并且应该清除当前的错误。
I am trying to invoke Groovy inside Hudson (using groovy plugin) to get some properties for our build. But I am getting this exception:
groovy.lang.MissingPropertyException: No such property: manager for class: Script1
I get this with the following line:
def buildNUmber = manager.build.number
This happens when I run as an inline command within Jenkins as well as using a script:
I tried the solution below, but it fails during the declaration itself (line two):
Binding binding = new Binding();
binding.setVariable("manager", manager);
GroovyShell shell = new GroovyShell(binding);
shell.evaluate(new File("d:/dev/others/hudson/userContent/ScriptStuff.groovy").text);
The above is run using: Groovy command. And when I run the build it errors and complains about the line - binding.setVariable("manager", manager);
When I use the Groovy script file, then it complains about:
def buildNumber = manager.build.number
Both errors are : groovy.lang.MissingPropertyException: No such property: manager for class: Script1
Tried everything mentioned in this thread as well:
I am using Hudson 2.2.1 and Groovy 2.1.3. What could be wrong?
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.
这篇关于groovy.lang.MissingPropertyException:没有这样的属性:类的经理:Script1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!