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

EnvInject doesn't pass variables defined in prebuild step if maven project is used

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Windows
      Jenkins 1.467
      EnvInject 1.55

      To reproduce:
      Create maven2 project
      Add prebuild step: Inject environment variables, add to property content field: "VAR123=Value123"
      Set maven goals: "clean -Dparam=${VAR123}"
      Build project

      Logs:
      Executing Maven: -B -f C:\Jenkins\jobs(Temp)\workspace\pom.xml clean -Dparam=${VAR123}

      Update: The bug is reproducible with Jenkins 1.471

          [JENKINS-14193] EnvInject doesn't pass variables defined in prebuild step if maven project is used

          Hello,
          I would like to know what is the current status of solution for this problem ? Because this issue made Jenkins jobs (with EnvInject) almost not user friendly usable ...
          Exists some way hot to speed this up ?
          Best regards,
          Pavel C.

          Pavel Cervenka added a comment - Hello, I would like to know what is the current status of solution for this problem ? Because this issue made Jenkins jobs (with EnvInject) almost not user friendly usable ... Exists some way hot to speed this up ? Best regards, Pavel C.

          Dexter Hu added a comment - - edited

          I need to do some REST call to get maven goal parameters.
          and pass these "key=value" from environment file to maven goals
          -Dkey=value

          Dexter Hu added a comment - - edited I need to do some REST call to get maven goal parameters. and pass these "key=value" from environment file to maven goals -Dkey=value

          Dexter Hu added a comment -

          Our current workaround is to run mvn in "Execute Shell".

          Dexter Hu added a comment - Our current workaround is to run mvn in "Execute Shell".

          Jaime Gago added a comment -

          Our work around is to generate a "maven-settings.xml" as a pre build step via a script available in the checkout and configure Jenkins to use that custom settings file in the job maven settings.

          Jaime Gago added a comment - Our work around is to generate a "maven-settings.xml" as a pre build step via a script available in the checkout and configure Jenkins to use that custom settings file in the job maven settings.

          Please note, that in pre-scm step the injected variables are working. See https://wiki.jenkins-ci.org/display/JENKINS/pre-scm-buildstep

          Gábor Lipták added a comment - Please note, that in pre-scm step the injected variables are working. See https://wiki.jenkins-ci.org/display/JENKINS/pre-scm-buildstep

          Workaround : The older Envfile plugin is working (Jenkins 1.574) with Maven goal and options field.

          Hugo de Paix de Coeur added a comment - Workaround : The older Envfile plugin is working (Jenkins 1.574) with Maven goal and options field.

          Doron Shai added a comment -

          Any estimation if this issue will be fixed and when? it is quite an annoying bug

          Doron Shai added a comment - Any estimation if this issue will be fixed and when? it is quite an annoying bug

          Hi, i think this not EnvInject plugin issue, because i injected env and parameter variables with groovy and they are not available in Maven build step. #JENKINS-20884 seems the root of this issue.

          Kanstantsin Shautsou added a comment - Hi, i think this not EnvInject plugin issue, because i injected env and parameter variables with groovy and they are not available in Maven build step. # JENKINS-20884 seems the root of this issue.

          Daniel Beck added a comment -

          This one can easily be reproduced using any maven-based project (you need a pom.xml) and the goal help:system. The environment variables defined in "Inject Environment Variables" Pre Step are not defined in the context of the maven build of the maven project, only those from Build Environment "Inject environment variables to the build process" are.

          Daniel Beck added a comment - This one can easily be reproduced using any maven-based project (you need a pom.xml) and the goal help:system . The environment variables defined in "Inject Environment Variables" Pre Step are not defined in the context of the maven build of the maven project, only those from Build Environment "Inject environment variables to the build process" are.

          Kanstantsin Shautsou added a comment - - edited

          Fixed in 2.7 maven-plugin version. Details: JENKINS-20884
          2.7 will appear in update center when INFRA-178 will be resolved.
          Markus Meisterernst, if it solves your issue you may donate based on this info https://wiki.jenkins-ci.org/display/JENKINS/Donation

          Kanstantsin Shautsou added a comment - - edited Fixed in 2.7 maven-plugin version. Details: JENKINS-20884 2.7 will appear in update center when INFRA-178 will be resolved. Markus Meisterernst, if it solves your issue you may donate based on this info https://wiki.jenkins-ci.org/display/JENKINS/Donation

            gbois Gregory Boissinot
            romchick Roman Milyuchikhin
            Votes:
            8 Vote for this issue
            Watchers:
            20 Start watching this issue

              Created:
              Updated:
              Resolved: