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

env Variables can not be resolved in "predefined parameters" textfield

      usecase:
      JobA wants to pass its name (%JOB_NAME%) to JobB. Therefore in the configuration of JobA the predefined parameters textfield is used to resolve the name but does not work as expected. Instead the whole string "%JOB_NAME%" is passed instead of "JobA". Here how I configured it:

      – JobA-------

      • predefined parameters:
        myJobName=%JOB_NAME%

      =>pass parameter on to JobB

      – JobB--------

      • bash command(win7)
        echo %myJobName%

      =>output: echo %JOB_NAME%
      %JOB_NAME%

      cheers
      Ignaz

          [JENKINS-15117] env Variables can not be resolved in "predefined parameters" textfield

          Stein Welberg added a comment -

          I have the same issue but for linux environment variables.

          During job execution I execute a shell script that sets an environment variable say GINI_VERSION.

          When I enter this variable in the predefined parameters field like version=${GINI_VERSION} or $GINI_VERSION. In the next job the entire string is passed and the variable is not resolved.

          Stein Welberg added a comment - I have the same issue but for linux environment variables. During job execution I execute a shell script that sets an environment variable say GINI_VERSION. When I enter this variable in the predefined parameters field like version=${GINI_VERSION} or $GINI_VERSION. In the next job the entire string is passed and the variable is not resolved.

          cjo9900 added a comment -

          looks like the issue is fixed in commit
          https://github.com/jenkinsci/parameterized-trigger-plugin/commit/16586248c382ef417e0aaa1d2cdb00baee87ec18

          for inclusion into version 2.17.

          Note you need to specify the predefined parameters using the myJobName=$JOB_NAME instead of the windows %JOB_NAME% style, as mentioned in the help "Current build parameters and/or environment variables can be used in form: ${PARAM} or $PARAM."

          You can test using the built version at https://jenkins.ci.cloudbees.com/job/plugins/job/parameterized-trigger-plugin/1/org.jenkins-ci.plugins$parameterized-trigger/

          cjo9900 added a comment - looks like the issue is fixed in commit https://github.com/jenkinsci/parameterized-trigger-plugin/commit/16586248c382ef417e0aaa1d2cdb00baee87ec18 for inclusion into version 2.17. Note you need to specify the predefined parameters using the myJobName=$JOB_NAME instead of the windows %JOB_NAME% style, as mentioned in the help "Current build parameters and/or environment variables can be used in form: ${PARAM} or $PARAM." You can test using the built version at https://jenkins.ci.cloudbees.com/job/plugins/job/parameterized-trigger-plugin/1/org.jenkins-ci.plugins$parameterized-trigger/

          cjo9900 added a comment -

          @Stein Welberg
          if you want to use variables that are set in a shell, you will need to add them to the Jenkins build Environment first, otherwise they will only be available for the life of that shell session (buildstep).

          You can do this by writing them to a properties file (KEY=VALUE format) in the workspace and then using the EnvInject plugin[1] to add them from that as the next build step, which will make the variables available from that point on.

          [1] https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin

          cjo9900 added a comment - @Stein Welberg if you want to use variables that are set in a shell, you will need to add them to the Jenkins build Environment first, otherwise they will only be available for the life of that shell session (buildstep). You can do this by writing them to a properties file (KEY=VALUE format) in the workspace and then using the EnvInject plugin [1] to add them from that as the next build step, which will make the variables available from that point on. [1] https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin

          ignaz reicht added a comment -

          thank you for the updates!

          ignaz reicht added a comment - thank you for the updates!

          Stein Welberg added a comment -

          Thanks for the update @cjo9900. We did something similar to the fix you suggested!

          Stein Welberg added a comment - Thanks for the update @cjo9900. We did something similar to the fix you suggested!

          cjo9900 added a comment -

          Fixed in 2.17

          cjo9900 added a comment - Fixed in 2.17

            cjo9900 cjo9900
            ireicht ignaz reicht
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: