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

envinject fails to "really" set/override build parameters

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      If you load a properties file as a build step, that overrides one or more build parameters, the injected variables will show up in the "Injected Environment Variables View", but the subsequent build steps will be provided with whatever was specified in the build parameter at the start of the build.

      Consider the following:
      Step 1 (generate the params.properties file)
      cd sast_product
      ./waf configure
      waf params

      Here is the resulting file's contents:
      SIM_REV = 81b806d6c4165277ad456a3ffd7ee2c5e0a9ed73
      SIM_REMOTE_REV = d82501d4a73c200974138016f3b2628d0bbf0366
      SIM_UI_REV = 2a0aef21282b1277f75555e9c68e4ace8deed055
      FSW_CONTAINER_REV = 1e8d2005a045ac51219a1fd8915c7bd0f4f8a177
      SIM_COMMON_REV = 6315defaf0c7376f2889bda3473828e2fbf2f743
      SIM_INTERFACE_REV = 88c48d1349fb90cddbcaa1a21e93eee20cb15687
      AST_REV = 8f947e56c1a6693687e8097fb50bba1626989ea6
      WILLY_WONKA = harris

      All but the last one map to build parameters. The last one is NOT a build parameter. Just a fake variable I added for test purposes.

      Step 2 (Inject Environment variables)
      Properties File Path: sast_product/build/params.properties
      Console output:
      [EnvInject] - Injecting environment variables from a build step.
      [EnvInject] - Injecting as environment variables the properties file path 'sast_product/build/params.properties'
      [EnvInject] - Variables injected successfully.

      Step 3 (Execute shell and print the variables)
      echo $SIM_COMMON_REV
      echo $SIM_INTERFACE_REV
      echo $WILLY_WONKA
      Console output:
      [sast_product_linux64] $ bash -xe /tmp/hudson6024044080448978568.sh
      + echo default
      default
      + echo default
      default
      + echo harris

      You can see what's set in the environment are the build parameters ("default" is the default parameter value for SIM_COMMON_REV and SIM_INTERFACE_REV) and not the injected variables from the previous step. The dummy variable I added to the properties file that doesn't attempt to shadow a build parameter prints out OK.

      I'm attaching the config.xml, but I'm hoping this description will suffice.

        Attachments

          Issue Links

            Activity

            Hide
            danielbeck Daniel Beck added a comment -

            Recent versions of the plugin added a switch to Prepare an environment to enable/disable overriding already defined environment variables (or something like that). Maybe that's related.

            The UI is a bit weird, as it affects everything envinject does in a job, not just the Prepare step, and you don't need to have anything else in there for the option to be effective.

            Show
            danielbeck Daniel Beck added a comment - Recent versions of the plugin added a switch to Prepare an environment to enable/disable overriding already defined environment variables (or something like that). Maybe that's related. The UI is a bit weird, as it affects everything envinject does in a job, not just the Prepare step, and you don't need to have anything else in there for the option to be effective.
            Hide
            kirillp Kirill Popov added a comment -

            The issue is still present in plugin version 1.91.3 with Jenkins ver. 1.605
            There is no difference if properties are being injected from file or from the field in job configuration - if the variable is one of build parameters, it's not being overridden.

            Show
            kirillp Kirill Popov added a comment - The issue is still present in plugin version 1.91.3 with Jenkins ver. 1.605 There is no difference if properties are being injected from file or from the field in job configuration - if the variable is one of build parameters, it's not being overridden.
            Hide
            o2themar Omar Ali added a comment -

            This issue is still present in Jenkins version 2.66 with Environment Injector plugin version 2.1.2. None of the parameter build environment variables can be overridden. 

            Show
            o2themar Omar Ali added a comment - This issue is still present in Jenkins version 2.66 with Environment Injector plugin version 2.1.2. None of the parameter build environment variables can be overridden. 
            Hide
            jwillemsen Johnny Willemsen added a comment -

            See the same happening now with jenkins 2.60.1 and envinject 2.1.3

            Show
            jwillemsen Johnny Willemsen added a comment - See the same happening now with jenkins 2.60.1 and envinject 2.1.3
            Hide
            pjdarton pjdarton added a comment -

            Ditto: Still present in Jenkins 2.89.2 with envinject 2.1.5

            However, I'm pretty sure it was "working for us" when we were using Jenkins 2.46.3 and envinject 1.93.1.  We've recently upgraded both Jenkins and envinject and we're now noticing this problem - setting new environment variables works, but you can't override ones provided by the rest of Jenkins (e.g. ones set in http://localhost:8080/configure -> "Global properties" -> "Environment variables").

            I've tried ticking the "Override Build Parameters" checkbox but that still doesn't allow the "Properties Content" section to override variables set in http://localhost:8080/configure -> "Global properties" -> "Environment variables".

             

            I have found a (non-ideal) workaround:  Duplicate the settings so it's set both in the General "Prepare an environment for the run" section and the Build Environment "Inject environment variables to the build process" section.  It would appear that this latter section overrides as expected (but if you only put your variables in this section then the variables aren't available during the SCM checkout stage).

            Show
            pjdarton pjdarton added a comment - Ditto: Still present in Jenkins 2.89.2 with envinject 2.1.5 However, I'm pretty sure it was "working for us" when we were using Jenkins 2.46.3 and envinject 1.93.1.  We've recently upgraded both Jenkins and envinject and we're now noticing this problem - setting new environment variables works, but you can't override ones provided by the rest of Jenkins (e.g. ones set in http://localhost:8080/configure -> "Global properties" -> "Environment variables"). I've tried ticking the "Override Build Parameters" checkbox but that still doesn't allow the "Properties Content" section to override variables set in http://localhost:8080/configure -> "Global properties" -> "Environment variables".   I have found a (non-ideal) workaround:  Duplicate the settings so it's set both in the General "Prepare an environment for the run" section and the Build Environment "Inject environment variables to the build process" section.  It would appear that this latter section overrides as expected (but if you  only put your variables in this section then the variables aren't available during the SCM checkout stage).

              People

              • Assignee:
                gbois Gregory Boissinot
                Reporter:
                mears Josh Davidson
              • Votes:
                16 Vote for this issue
                Watchers:
                23 Start watching this issue

                Dates

                • Created:
                  Updated: