jenkins - 如何使用 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)
解决方案
也许这会有所帮助。
构建作业:'作业路径',等待:'false',参数:[字符串(名称:'xx',值:“$xx”),字符串(名称:'yy',值:“$yy”)]
推荐阅读
- android - 如何有条件地在 ionic 4 中设置根页面?
- asp.net-mvc - 在 httppost asp.net mvc 之后返回部分视图
- javascript - 从状态中随机选择地图中的索引/洗牌
- ansible - 如何使用 ansible 在客户端机器上安装软件包
- kubernetes - Prometheus:将矩阵推送到 PushGateway 的代理组件
- c# - 如何在 Excel 中使用正确的列打开 CSV 文件
- flutter - Flutter - PageView中的错误,参数不存在
- rpm - rpm.spec 中的 %attr 不采用环境变量的值
- java - 使用 Dockerfile 将 excel (.xls) 文件复制到容器
- excel - 相同的代码在不同的用户表单上工作方式不同