首页 > 解决方案 > 如何使用 postbuild groovy 构建下游作业

问题描述

我正在尝试使用 jenkins 中的 groovy 脚本构建下游作业。
我已经安装了Groovy Postbuild 插件,它在自由式作业的 postbuild 部分为我提供了以下选项。
堆 请注意TestDownstream是我想作为后期构建操作启动/触发/调用的作业名称。

我努力了

build 'TestDownstream'
node{
   build 'TestDownstream'
}
node{
   stage('TestDownstream')
}

还有一些像这样的变体。

我收到此错误为:

Groovy script failed:

groovy.lang.MissingMethodException: No signature of method: Script1.build() is applicable for argument types: (java.lang.String) values: [TestDownstream]
Possible solutions: find(), find(groovy.lang.Closure), wait(), run(), run(), dump()
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:81)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
    at Script1.run(Script1.groovy:1)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:377)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:314)
    at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:406)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
    at hudson.model.Build$BuildExecution.post2(Build.java:177)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
    at hudson.model.Run.execute(Run.java:1932)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)

标签: jenkinsgroovybuildpipeline

解决方案


也许这会有所帮助。

构建作业:'作业路径',等待:'false',参数:[字符串(名称:'xx',值:“$xx”),字符串(名称:'yy',值:“$yy”)]


推荐阅读