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

Cannot access environment variable from parameterized plugin in pipeline checkout

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • workflow-job-plugin
    • None
    • Jenkins v1.639, Pipeline 2.2, Environment Injector Plugin 1.92.1

      I have a pipeline job set up as such:

      • "This build is parameterized" with a "PRODUCT_CONFIG_BRANCH" string parameter
      • "Pipeline script from SCM" with branch specifier `refs/heads/$PRODUCT_CONFIG_BRANCH`
        When I run the build, it never seems to read the $PRODUCT_CONFIG_BRANCH variable.

      If I set the variable in the Properties Content section, it uses this. However, I'd prefer to be able to easily set it every time I click Build.

          [JENKINS-36411] Cannot access environment variable from parameterized plugin in pipeline checkout

          Wayne Warren added a comment -

          I think I am currently running into this same issue, attempting to set the refspec and branch values from job parameters does not work because parameters are not interpreted at cpsScm checkout time.

          Wayne Warren added a comment - I think I am currently running into this same issue, attempting to set the refspec and branch values from job parameters does not work because parameters are not interpreted at cpsScm checkout time.

          subbarao p added a comment -

          Are you using jenkins which version ?
          jenkins 1.6 version is working without any scripting parameterized.
          select your job configuration this build is parameterized — select string parameter---give only name---you are not enter default value.
          you pass the parameter another job. Goto second job build---- addbuild step----execute windowbatch command
          call the variable here $name.
          when u run your first job asking buildwith parameter--click-and write your valuethen build--
          its automatically come to variable value in another job

          subbarao p added a comment - Are you using jenkins which version ? jenkins 1.6 version is working without any scripting parameterized. select your job configuration this build is parameterized — select string parameter--- give only name ---you are not enter default value. you pass the parameter another job. Goto second job build---- addbuild step----execute windowbatch command call the variable here $name. when u run your first job asking buildwith parameter-- click - and write your value then build -- its automatically come to variable value in another job

          Oleg Nenashev added a comment -

          This issue is not related to EnvIject plugin - this plugin does not support Pipeline at all

          Oleg Nenashev added a comment - This issue is not related to EnvIject plugin - this plugin does not support Pipeline at all

          malcolm crum added a comment -

          Thanks, that makes sense. In that case this ticket can be closed.

          Is there a way to do something similar with Pipeline, then? I.e. click Build With Parameters, enter the name of a branch, and have pipeline checkout that branch and run the jenkinsfile in it?

          malcolm crum added a comment - Thanks, that makes sense. In that case this ticket can be closed. Is there a way to do something similar with Pipeline, then? I.e. click Build With Parameters, enter the name of a branch, and have pipeline checkout that branch and run the jenkinsfile in it?

          Oleg Nenashev added a comment -

          crummy By now I see no evidence you use EnvInject. From what I see you just use Job Parameter (core feature) which does something with Pipeline settings (Pipeline Job plugin). Please correct me if I'm wrong.

          P.S: BTW, maybe your case can be solved with Pipeline Multi-Branch plugin instead of a common Pipeline

          Oleg Nenashev added a comment - crummy By now I see no evidence you use EnvInject. From what I see you just use Job Parameter (core feature) which does something with Pipeline settings (Pipeline Job plugin). Please correct me if I'm wrong. P.S: BTW, maybe your case can be solved with Pipeline Multi-Branch plugin instead of a common Pipeline

          Andrew Bayer added a comment -

          Can you provide a reproduction case? If not, I'm going to close this as cannot reproduce.

          Andrew Bayer added a comment - Can you provide a reproduction case? If not, I'm going to close this as cannot reproduce.

            Unassigned Unassigned
            crummy malcolm crum
            Votes:
            3 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: