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

Injected Jenkins build env variables not resolved/forwarded

      In Jenkins, in a Maven build project, I have a pre build step that executes a shell command with a pre build step of type "Execute shell". In this shell script, I fill a properties file with values:
      echo values=1,2,3 > data.properties.

      As the "Post-build Actions", I deploy artifacts to
      Artifactory. Although I check "Include all environment variables", my
      environment variable is not listed in Artifactory's "Environment" panel
      for builds. In Jenkins, I've also added the environment variable in
      "Deployment properties" under the section "Deploy maven artifacts". But in
      Artifactory, the variable was not resolved in the Repository Browser >
      "Metadata" of the deployed artifact.

      Solely defining the values and properties in the "build environment" section does not work, because the properties file is filled during build time.

      From JFrog/Artifactory I got the answer:
      "Our plugin has an extension point which gathers all the environment variables and passing them through to our extractors (Maven/Gradle/Ivy).
      This procedure happens before the EnvInject plugin, I'm afraid we cannot change this behavior since the order is out of our control."

      How can I pass my generated values along to the post build step, or more generally asking: is there any way to compute values during build time inside a shell skript and pass them along as environment variables to the post build action that deploys the artifacts to Artifactory?

      The attached screenshots were created by the Artifactory team.

      Thanks!

          [JENKINS-15112] Injected Jenkins build env variables not resolved/forwarded

          I'm sorry for my late reply.
          Firstly, EnvInject plugin and Artifactory plugin are independent. The main goal of EnvInject plugin is to provide the ability to inject environment variables before a SCM checkout, after a SCM checkout, at a build step and at a post build step.

          For each build, all injected environment variables can be retrieved through the dashboard, through a file (multiple format are available, default is txt) in the build directory in the JENKINS_HOME, by REST API (refer to the wiki plugin page).

          For your use cas, you are able to load your data.properties from the EnvInject plugin and keys will be exported as environment variable names.
          After I don't know how to integrate it with the Artifactory plugin

          EnvInject is for now an important plugin in the Jenkins ecosystem and it is the only way to manage properly your job environment variables.
          If Artifactory plugin gather environment variables before the end of the EnvInject plugin, the conclusion is: Artifactory plugin doesn't gather the right environment variables.
          Therefore, there are two solutions:
          1) Artifactory evolves
          2) Switch your job to a more suited plugin

          Gregory Boissinot added a comment - I'm sorry for my late reply. Firstly, EnvInject plugin and Artifactory plugin are independent. The main goal of EnvInject plugin is to provide the ability to inject environment variables before a SCM checkout, after a SCM checkout, at a build step and at a post build step. For each build, all injected environment variables can be retrieved through the dashboard, through a file (multiple format are available, default is txt) in the build directory in the JENKINS_HOME, by REST API (refer to the wiki plugin page). For your use cas, you are able to load your data.properties from the EnvInject plugin and keys will be exported as environment variable names. After I don't know how to integrate it with the Artifactory plugin EnvInject is for now an important plugin in the Jenkins ecosystem and it is the only way to manage properly your job environment variables. If Artifactory plugin gather environment variables before the end of the EnvInject plugin, the conclusion is: Artifactory plugin doesn't gather the right environment variables. Therefore, there are two solutions: 1) Artifactory evolves 2) Switch your job to a more suited plugin

          Oleg Nenashev added a comment -

          michaelhuettermann could you please either retest or close this issue? 

          Oleg Nenashev added a comment - michaelhuettermann could you please either retest or close this issue? 

            gbois Gregory Boissinot
            michaelhuettermann Michael Hüttermann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: