Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-14739

EnvInject params are overwritten by default string params

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Major Major
    • envinject-plugin
    • None
    • Jenkins 1.455 running on Ubuntu 11.04

      A parameter created by EnvInject by a parent job will be overwritten by triggered jobs if a string parameter already exists.

      For example:
      1) A parameterized parent project exists. It has a string parameter (defaulted to one):
      PARAM_SLAVE_NUMBER=1
      It creates a new parameter with EnvInject:
      PARAM_SLAVE=Win7-Slave-$PARAM_SLAVE_NUMBER
      It then triggers a child project with current build paramters
      2) The child project is parameterized with a string parameter as well:
      PARAM_SLAVE=Win7-Slave-2
      The child project then runs a script on the node specified by PARAM_SLAVE.

      The expected operation is that since string parameters should only take the default values when they're not set already (pseudocode: IF NOT EXISTS($PARAM_SLAVE)

      { PARAM_SLAVE=Win7-Slave-2 }

      ), EnvInject should set PARAM_SLAVE first, and the child project should not re-set PARAM_SLAVE, however, that's not what happens. In the case above, the script will always be run on Win7-Slave-2, no matter what PARAM_SLAVE_NUMBER is set to.

          [JENKINS-14739] EnvInject params are overwritten by default string params

          Do you use the paramaterized-plugin in addition of the EnvInject plugin?
          Could you attach your jobs configurations files (config.xml)?
          Thanks

          Gregory Boissinot added a comment - Do you use the paramaterized-plugin in addition of the EnvInject plugin? Could you attach your jobs configurations files (config.xml)? Thanks

          Ben Kershner added a comment -

          I can't post my actual jobs due to security and proprietary information reasons, but I created the scenario listed above and included it in the zip.

          To the best of my knowledge (I didn't build this Jenkins server from the ground up, so I'm still learning what's an out-of-the-box built-in feature and what's a plugin), I do use parameters when creating the job (built-in?), but I do not use the Parameterized Trigger Plugin.

          Check JENKINS-14739.zip for the configs, and if you run them, take note of the differences in the Injected Environment Variables for each.

          Ben Kershner added a comment - I can't post my actual jobs due to security and proprietary information reasons, but I created the scenario listed above and included it in the zip. To the best of my knowledge (I didn't build this Jenkins server from the ground up, so I'm still learning what's an out-of-the-box built-in feature and what's a plugin), I do use parameters when creating the job (built-in?), but I do not use the Parameterized Trigger Plugin. Check JENKINS-14739 .zip for the configs, and if you run them, take note of the differences in the Injected Environment Variables for each.

          Ben Kershner added a comment -

          config.xml files for the scenario in the description.

          Ben Kershner added a comment - config.xml files for the scenario in the description.

          Gregory Boissinot added a comment - - edited

          Your example is quite difficult for me.
          Do you use environment variables for selecting your nodes?
          Is it possible to provide a more simple scenario?

          Gregory Boissinot added a comment - - edited Your example is quite difficult for me. Do you use environment variables for selecting your nodes? Is it possible to provide a more simple scenario?

          Any update?

          Gregory Boissinot added a comment - Any update?

          Is it possible to help me to provide a simpler example?

          Gregory Boissinot added a comment - Is it possible to help me to provide a simpler example?

          I'm afraid I can't solve this issue.
          Please help me by providing more information or further investigation?

          Gregory Boissinot added a comment - I'm afraid I can't solve this issue. Please help me by providing more information or further investigation?

          Daniel Beck added a comment - - edited

          This looks to me like it works as intended. The parameterized trigger only passes actual build parameters, not all variables defined as environment variables.

          In many of my builds, I have a few parameters at most, and often dozens of environment variables to configure generic build scripts to the specific job (like paths to certain programs in specific versions). Please also note that many other environment variables exist by default, or are defined and redefined in the global Jenkins configuration and slave configuration. And passing PATH would quickly wreck havoc on downstream builds running on different machines.

          An easy workaround for this issue also exists: Just add a "predefined parameters" element from the parameterized build trigger plugin, and enter PARAM_SLAVE=$PARAM_SLAVE to override the default value of the slave. Skip the "current build parameters" entirely, it's simply not what you want.

          Daniel Beck added a comment - - edited This looks to me like it works as intended. The parameterized trigger only passes actual build parameters , not all variables defined as environment variables. In many of my builds, I have a few parameters at most, and often dozens of environment variables to configure generic build scripts to the specific job (like paths to certain programs in specific versions). Please also note that many other environment variables exist by default, or are defined and redefined in the global Jenkins configuration and slave configuration. And passing PATH would quickly wreck havoc on downstream builds running on different machines. An easy workaround for this issue also exists: Just add a "predefined parameters" element from the parameterized build trigger plugin, and enter PARAM_SLAVE=$PARAM_SLAVE to override the default value of the slave. Skip the "current build parameters" entirely, it's simply not what you want.

            gbois Gregory Boissinot
            benkershner Ben Kershner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: