Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pre-Defined parameters no longer passed to child job

Tags:

jenkins

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.

Let me illustrate: Let's say that I have a parent job and a child job.

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.

In Jenkins 1.618, when child was triggered this way, it would have FOO set as a parameter, with a value of BAR.

But in 2.3, FOO is not set on that build of child.

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.

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?

like image 528
PortMan Avatar asked May 16 '16 20:05

PortMan


People also ask

How does Jenkins pass parameters to a job?

Using build parameters, we can pass any data we want: git branch name, secret credentials, hostnames and ports, and so on. Any Jenkins job or pipeline can be parameterized. All we need to do is check the box on the General settings tab, “This project is parameterized”: Then we click the Add Parameter button.

What is the use of parameterized trigger plugin in Jenkins?

This plugin lets you trigger new builds when your build has completed, with various ways of specifying parameters for the new build. These new builds appear as "Subprojects" in the Jenkins UI when you are looking at a project that triggers them.


Video Answer


1 Answers

There are some solutions

  1. commabd line
    java -Dhudson.model.ParametersAction.keepUndefinedParameters=true -jar jenkins.war
  2. groovy
    import jenkins.model.*; System.setProperty("hudson.model.ParametersAction.keepUndefinedParameters", "true")
like image 161
Frank Yen Avatar answered Nov 06 '22 07:11

Frank Yen