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

Build script variables are not available in Predefined parameters

      Build script variables are not passed to parameterized builds via the "Predefined parameters".

      To test:

      1.) Create TEST build with Execute shell: export BUILD_JAVA=1
      2.) Trigger/call builds on other projects (parameterized build expecting BUILD JAVA)
      3.) Set $BUILD_JAVA as "Predefined parameters"
      4.) 1 is not passed to the parameterized build!

          [JENKINS-12415] Build script variables are not available in Predefined parameters

          cjo9900 added a comment -

          We are using using the parameters from one job to 5 chained jobs after that, with no issues at all.

          Two possible issues here
          1. parameter values not passed from job A -> job B

          Look like you config is incorrect from the screen shots

          To pass just one of the parameters to the other jobs using the predefined parameters item you need to specify
          BUILD_JAVA=$BUILD_JAVA

          To pass all current parameters to it you should "Current build parameters" when adding the parameters

          2. Exported variable from shell not passed to called jobs.
          When doing export BUILD_JAVA=1 from a shell script this does not get passed back into the job environment setting so these are only used within the context of that shell script and spawned processes.
          To show this add a second shell build step and print the environment variables using env an then check for the exported item, you will see it is not present.

          To pass these values along to later build steps print them to a file in the standard parameter format of KEY=VALUE and then use the EnvInject plugin build step to add them to the run environment from the file created

          Suggest closing the error as there is no real changes that can be made to change the current behaviour as it is a known core issue with a solution as defined above

          cjo9900 added a comment - We are using using the parameters from one job to 5 chained jobs after that, with no issues at all. Two possible issues here 1. parameter values not passed from job A -> job B Look like you config is incorrect from the screen shots To pass just one of the parameters to the other jobs using the predefined parameters item you need to specify BUILD_JAVA=$BUILD_JAVA To pass all current parameters to it you should "Current build parameters" when adding the parameters 2. Exported variable from shell not passed to called jobs. When doing export BUILD_JAVA=1 from a shell script this does not get passed back into the job environment setting so these are only used within the context of that shell script and spawned processes. To show this add a second shell build step and print the environment variables using env an then check for the exported item, you will see it is not present. To pass these values along to later build steps print them to a file in the standard parameter format of KEY=VALUE and then use the EnvInject plugin build step to add them to the run environment from the file created Suggest closing the error as there is no real changes that can be made to change the current behaviour as it is a known core issue with a solution as defined above

          Aaron Stone added a comment -

          Hey, are you sure this is still broken? I'm pretty sure I use this functionality. (I linked to JENKINS-14251, but I think these might be two separate sources of variables.)

          Aaron Stone added a comment - Hey, are you sure this is still broken? I'm pretty sure I use this functionality. (I linked to JENKINS-14251 , but I think these might be two separate sources of variables.)

          cjo9900 added a comment -

          Not a defect so closing and is not linked to the EnvInject plugin so removing that link.

          cjo9900 added a comment - Not a defect so closing and is not linked to the EnvInject plugin so removing that link.

            cjo9900 cjo9900
            sherbo sherban drulea
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: