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

EnvInject Plugin is only working to a limited extent in combination with the docker build environment

      When using the env inject plugin, only those properties are injected that are specified before the scm checkout.

      Properties that are set after the scm checkout aren't available during the build execution within the docker container.

          [JENKINS-29621] EnvInject Plugin is only working to a limited extent in combination with the docker build environment

          Not sure this is feasible, as the docker container environment is set when container is started, and subsequent commands ran with `docker exec` can't amend it.

          Can't you set environment before checkout ? What's your use-case ?

          Nicolas De Loof added a comment - Not sure this is feasible, as the docker container environment is set when container is started, and subsequent commands ran with `docker exec` can't amend it. Can't you set environment before checkout ? What's your use-case ?

          We are facing the same problem. As I can see the environment present and used during container start is the host environment present during Jenkins node start (may be days or weeks ago) including environment variables configured for this node (before node startup).
          There is no way to add additional environment variables (e.g. using EnvInject) as it seems to be only working for build steps and the Docker container start isn't such a dedicated step but "fancy work in the background".

          Stefan Kahlhöfer added a comment - We are facing the same problem. As I can see the environment present and used during container start is the host environment present during Jenkins node start (may be days or weeks ago) including environment variables configured for this node (before node startup). There is no way to add additional environment variables (e.g. using EnvInject) as it seems to be only working for build steps and the Docker container start isn't such a dedicated step but "fancy work in the background".

          ndeloof: In JENKINS-29677 you mentioned priority of concurrent Build Wrappers. If you find a solution, this may be the trick for this issue as well.

          Stefan Kahlhöfer added a comment - ndeloof : In JENKINS-29677 you mentioned priority of concurrent Build Wrappers. If you find a solution, this may be the trick for this issue as well.

          skahlhoefer no, issue here is that you can't change environment for a container after it has been started, so only variable set before the build start can be used.

          Nicolas De Loof added a comment - skahlhoefer no, issue here is that you can't change environment for a container after it has been started, so only variable set before the build start can be used.

          Tom Canova added a comment - - edited

          I start using the CloudBees docker build environment plugin a couple of weeks ago and all was going well until I install the EnvInject plugin. After installing the plugin my shell build step can't find ls (or npm or a number of other things which are in the container)

          /tmp/hudson4662764981604235729.sh: line 2: ls: command not found
          Build step 'Execute shell' marked build as failure

          After uninstalling the EnvInject plugin, all works again.

          The problem occurs in the build when the EnvInject plugin options are not being used. I'm glad I don't have to have the EnvInject plugin

          Tom Canova added a comment - - edited I start using the CloudBees docker build environment plugin a couple of weeks ago and all was going well until I install the EnvInject plugin. After installing the plugin my shell build step can't find ls (or npm or a number of other things which are in the container) /tmp/hudson4662764981604235729.sh: line 2: ls: command not found Build step 'Execute shell' marked build as failure After uninstalling the EnvInject plugin, all works again. The problem occurs in the build when the EnvInject plugin options are not being used. I'm glad I don't have to have the EnvInject plugin

            Unassigned Unassigned
            emicify Michael Süß
            Votes:
            7 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: