预定义参数不再传递给子作业 [英] Pre-Defined parameters no longer passed to child job
问题描述
我今天将Jenkins从1.618升级到2.3.这包括安装它推荐的一堆插件(大多数是管道插件及其依赖项).
I upgraded Jenkins today from 1.618 to 2.3. This included installing a whole bunch of plugins that it recommended (Mostly Pipeline plugins and their dependencies).
自升级以来,每当一个工作开始另一个工作时,我都会收到一个新的错误(或者至少是一个新的不良行为).除非子作业已经定义了这些键,否则任何作为预定义参数"传递给子项的值都将被忽略.
Since the upgrade, I get a new error (or, at least, a new unwanted behavior) any time a job kicks off another job. Any values passed to the child as "Predefined parameters" are ignored unless the child job already has those keys defined.
让我举例说明:假设我有一个parent
工作和一个child
工作.
Let me illustrate: Let's say that I have a parent
job and a child
job.
Parent
通过在其他项目上触发参数化的生成"启动"child
".在该构建后操作"的定义中的预定义参数"下,定义了FOO=BAR
.
Parent
launches child
through a "Trigger parameterized build on other projects" Post-build Action. In the definition of that Post-build Action, under the "Predefined parameters", I have FOO=BAR
defined.
在Jenkins 1.618中,以这种方式触发child
时,会将FOO
设置为参数,其值为BAR
.
In Jenkins 1.618, when child
was triggered this way, it would have FOO
set as a parameter, with a value of BAR
.
但是在2.3中,未在该版本的child
上设置FOO
.
But in 2.3, FOO
is not set on that build of child
.
如果我修改child
,以使FOO
始终是该作业的参数,则它将从parent
中拾取FOO=BAR
设置.这是不可接受的解决方法,因为我们以这种方式传递了数十个参数,并且在两端定义它们太脆弱了,并且违反了不要重复自己"的原则.
If I modify child
so that FOO
is always a parameter of that job, it will then pick up the FOO=BAR
set from parent
. This is an unacceptable work-around because we pass dozens of parameters this way, and defining them on both ends is too fragile and violates the "don't repeat yourself" principle.
无论是通过在其他项目上触发参数化的构建"后生成操作还是通过MultiJob项目的MultiJob阶段触发子作业,我都得到相同的结果.
I get the same results whether I'm triggering the child job through through the "Trigger parameterized build on other projects" Post-build Action or through a MultiJob Phase of a MultiJob project.
这是否是预期的更改?它以前是否损坏过,而我们只是使用不正确?还是这是一个错误?
Is this an intended change? Was it broken before, and we were just using it incorrectly? Or is this a bug?
推荐答案
According to Jenkins 2 Security updates, you can bypass it by setting:
hudson.model.ParametersAction.keepUndefinedParameters = true
hudson.model.ParametersAction.keepUndefinedParameters=true
要验证此替代方法,请转到Manage Jenkins->脚本控制台,然后运行:
To validate this workaround, go to Manage Jenkins -> Script Console, and run:
System.setProperty("hudson.model.ParametersAction.keepUndefinedParameters", "true")
要使其永久存在,请按如下所示更改Jenkins参数(然后重新启动Jenkins):
To make it permanent, change Jenkins arguments as follow (and restart Jenkins afterwards):
在Windows上,在Jenkins主目录中编辑 jenkins.xml ,例如:
On Windows edit jenkins.xml in Jenkins home directory, for example:
<arguments>
-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle
-Dhudson.model.ParametersAction.keepUndefinedParameters=true
-jar "%BASE%\jenkins.war" --httpPort=8080
</arguments>
对于大多数Linux发行版,您可以在文件内修改 JENKINS_ARGS :
For most of the Linux distributions, you can modify JENKINS_ARGS inside file:
/etc/default/jenkins (或jenkins-oc)
/etc/default/jenkins (or jenkins-oc)
对于CentOS,修改文件内的 JENKINS_JAVA_OPTIONS :
For CentOS, modify JENKINS_JAVA_OPTIONS inside file:
/etc/sysconfig/jenkins (或jenkins-oc)
/etc/sysconfig/jenkins (or jenkins-oc)
这是已报告的受此问题影响的插件的列表,并且已经存在一个打开的错误: https://wiki.jenkins-ci .org/display/JENKINS/Plugins + affected + by + fix + for + SECURITY-170
Here's a list of reported plugins, that were affected by the issue, and has an open bug already: https://wiki.jenkins-ci.org/display/JENKINS/Plugins+affected+by+fix+for+SECURITY-170
这篇关于预定义参数不再传递给子作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!