1

我正在使用构建流程项目来组合两个不同的项目测试结果。然后我需要更改聚合测试结果的构建状态,所以我使用 groovy postbuild 来更改我的构建状态。如果有任何一个,则在该脚本中测试失败在任何项目中都失败了,然后我试图将构建状态更改为不稳定。为此,我正在使用 groovy 脚本从两个结果中计算失败计数。但是当我尝试这个时,它会抛出 NULL 指针异常。我在 groovy postbuild 中使用的脚本是

def testResult = manager.build.testResultAction.result
def fail = testResult.failCount
if(fail==NULL)
{ manager.buildSuccess() }
else
{ manager.buildUnstable() }

它抛出异常为

ava.lang.NullPointerException: Cannot get property 'result' on null object
at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:56)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:156)
at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
at Script1.run(Script1.groovy:1)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:166)
at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:362)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
at hudson.model.Run.execute(Run.java:1763)
at hudson.model.FreeStyleBuild.run``(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)

活动

4

0 回答 0