jenkins工作触发downstram工作,参数不起作用

时间:2016-10-06 18:04:58

标签: jenkins plugins docker

我正在尝试使用jenkins plugin执行下游作业,以将参数传递给下游作业。我已将以下配置添加为构建步骤:the following configuration as a build step:。顶级作业成功完成但是在下游作业中,我使用jenkins插件进行docker build和push,它不接受JBNAME:

Building in workspace /home/jenkins/workspace/dockerbuild
ERROR: Unrecognized macro '**JBNAME**' in 'url/repo/**${JBNAME**}'
org.jenkinsci.plugins.tokenmacro.MacroEvaluationException:               Unrecognized    macro 'JBNAME' in 'url/repo/**${JBNAME}**'
at  org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:207)
at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:246)
at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:232)
at com.cloudbees.dockerpublish.DockerBuilder$Perform.expandAll(DockerBuilder.java:324)
at com.cloudbees.dockerpublish.DockerBuilder$Perform.getImageTags(DockerBuilder.java:336)
at com.cloudbees.dockerpublish.DockerBuilder$Perform.exec(DockerBuilder.java:305)
at com.cloudbees.dockerpublish.DockerBuilder$Perform.access$100(DockerBuilder.java:291)
at com.cloudbees.dockerpublish.DockerBuilder.perform(DockerBuilder.java:262)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1720)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Build step 'Docker Build and Publish' marked build as failure
Finished: FAILURE

当我查看失败的构建页面上的参数链接时,该字段为空,它没有传递任何参数,包括当前或预定义: enter image description here 我此刻迷路了。我真的需要将上游作业名称传递给docker构建作业,以保留正确的容器命名。

非常感谢你!

1 个答案:

答案 0 :(得分:0)

最近的Jenkins版本不再允许未声明的参数。有关详细信息,请参阅相关的security advisory

在您的情况下,您可能只需将JBNAME声明为下游作业的参数。即选择 此构建在下游作业配置中已参数化,并添加名称为JBNAME的新字符串参数。