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

Verion 1.27 does not work with Tool Environment plugin

      We use the Tool Environment Plugin to set environment variables with path for tools. We used the SetEnv plugin before together with the TE plugin and the tool environment variables could be used in the SetEnv configuration. This does not work with the EnvInject plugin, which is supposed to replace the SetEnv plugin.

      Configuration:
      We have tool environment variables
      MAVEN_2_2_1_HOME
      JAVA_IBM_60_81_HOME
      ANT_1_6_5_HOME

      The SetEnv plugin set the environment for a build using these:
      PROJECT_TOP=${WORKSPACE}
      PROJECT_BUILD=$PROJECT_TOP/build
      PROJECT_RES=$PROJECT_TOP/delivery
      PROJECT_SRC=$PROJECT_TOP

      JAVA_HOME=${JAVA_IBM_60_81_HOME}

      PATH=${JAVA_HOME}/bin:${MAVEN_2_2_1_HOME}/bin:${ANT_1_6_5_HOME}/bin:$PATH

      This would work.

      Using the EnvInject plugin on a new Jenksin 1.451 installation, I was so far not able to find any configuration which would work. The EnvInject plugin does not see the tool environment variables, or the PATH variable. This are the results:

      [EnvInject] - Injecting environment variables from a build step.
      [EnvInject] - Injecting as environment variables the properties content
      BRANCH=trunk
      PROJECT_TOP=${WORKSPACE}
      PROJECT_BUILD=$PROJECT_TOP/build
      PROJECT_RES=$PROJECT_TOP/delivery
      PROJECT_SRC=$PROJECT_TOP
      JAVA_HOME=${JAVA_IBM_60_81_HOME}
      PATH=${JAVA_HOME}/bin:${MAVEN_2_2_1_HOME}/bin:${ANT_1_6_5_HOME}/bin:$PATH

      [EnvInject] - Variables injected successfully.
      [EnvInject] - Unset unresolved 'JAVA_HOME' variable.
      [EnvInject] - Unset unresolved 'PATH' variable.
      Setting ANT_1_6_5_HOME=/data/sourcecode/cbe-tools/ant/1.6.5
      Setting MAVEN_2_2_1_HOME=/data/sourcecode/cbe-tools/maven/2.2.1
      Setting JAVA_IBM_60_81_HOME=/data/build-env/java/ibm-java2-i386-6.0.8.1

      or:

      [EnvInject] - Executing scripts and injecting environment variables after the SCM step.
      [EnvInject] - Executing and processing the following script content:
      BRANCH=trunk

      PROJECT_TOP=${WORKSPACE}
      PROJECT_BUILD=$PROJECT_TOP/build
      PROJECT_RES=$PROJECT_TOP/delivery
      PROJECT_SRC=$PROJECT_TOP

      JAVA_HOME=${JAVA_IBM_60_81_HOME}

      PATH=${JAVA_HOME}/bin:${MAVEN_2_2_1_HOME}/bin:${ANT_1_6_5_HOME}/bin:$PATH

      [hourly] $ /bin/sh -xe /tmp/hudson6496656756456228415.sh
      + BRANCH=trunk
      + PROJECT_TOP=/data/sourcecode/domain/trunk/hourly
      + PROJECT_BUILD=/data/sourcecode/domain/trunk/hourly/build
      + PROJECT_RES=/data/sourcecode/domain/trunk/hourly/delivery
      + PROJECT_SRC=/data/sourcecode/domain/trunk/hourly
      + JAVA_HOME=
      + PATH=/bin:/bin:/bin:/data/build-env/java/ibm-java2-i386-6.0.8.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin
      [EnvInject] - Script executed successfully.
      Setting ANT_1_6_5_HOME=/data/sourcecode/cbe-tools/ant/1.6.5
      Setting MAVEN_2_2_1_HOME=/data/sourcecode/cbe-tools/maven/2.2.1
      Setting JAVA_IBM_60_81_HOME=/data/build-env/java/ibm-java2-i386-6.0.8.1

      This came closest, but the PATH variable cannot be seen:

      [EnvInject] - Injecting environment variables from a build step.
      Setting ANT_1_6_5_HOME=/data/sourcecode/cbe-tools/ant/1.6.5
      Setting MAVEN_2_2_1_HOME=/data/sourcecode/cbe-tools/maven/2.2.1
      Setting JAVA_IBM_60_81_HOME=/data/build-env/java/ibm-java2-i386-6.0.8.1
      [EnvInject] - Injecting as environment variables the properties content
      BRANCH=trunk
      PROJECT_TOP=${WORKSPACE}
      PROJECT_BUILD=$PROJECT_TOP/build
      PROJECT_RES=$PROJECT_TOP/delivery
      PROJECT_SRC=$PROJECT_TOP
      JAVA_HOME=${JAVA_IBM_60_81_HOME}
      PATH=${JAVA_HOME}/bin:${MAVEN_2_2_1_HOME}/bin:${ANT_1_6_5_HOME}/bin:$PATH

      [EnvInject] - Variables injected successfully.
      [EnvInject] - Unset unresolved 'PATH' variable.
      Setting ANT_1_6_5_HOME=/data/sourcecode/cbe-tools/ant/1.6.5
      Setting MAVEN_2_2_1_HOME=/data/sourcecode/cbe-tools/maven/2.2.1
      Setting JAVA_IBM_60_81_HOME=/data/build-env/java/ibm-java2-i386-6.0.8.1

          [JENKINS-12879] Verion 1.27 does not work with Tool Environment plugin

          Instead of use the couple EnvInject/Tool Environment plugin, I suggest you should use the coupld EnvInject/SharedObjects plugin. This latest plugin can export Toll installations as environment variables.

          Gregory Boissinot added a comment - Instead of use the couple EnvInject/Tool Environment plugin, I suggest you should use the coupld EnvInject/SharedObjects plugin. This latest plugin can export Toll installations as environment variables.

          Thanks for the tip. I have tried to use the Shared Object plugin instead. The problem remains because while the SO plugin does set the tool names as environment variables which can be used in the job, they can not be used, i.e. referenced, when injecting environment variables with EnvInject.

          I have a tool naem "Maven 2.2.1" which creates a env variable of the same name.
          When I set the environment with EnvInject, I have something like:

          MAVEN_BIN=${Maven 2.2.1}/bin

          This does not work, the variable "Maven 2.2.1" can not be resolved by EnvInject. Changing the tool name to contain an underscore instead of space did not help. Are the tool environment variables created by the SO plugin supposed to be referencable in EnvInject configuration?

          So far I have to return to SetEnv/ToolEnvironment because EnvInject cannot replace the functionality that combi provides. What I am trying to do is get tool paths in the PATH for jobs we run (i.e. an Ant job).

          Thanks for looking into it.

          Florian Zschocke added a comment - Thanks for the tip. I have tried to use the Shared Object plugin instead. The problem remains because while the SO plugin does set the tool names as environment variables which can be used in the job, they can not be used, i.e. referenced, when injecting environment variables with EnvInject. I have a tool naem "Maven 2.2.1" which creates a env variable of the same name. When I set the environment with EnvInject, I have something like: MAVEN_BIN=${Maven 2.2.1}/bin This does not work, the variable "Maven 2.2.1" can not be resolved by EnvInject. Changing the tool name to contain an underscore instead of space did not help. Are the tool environment variables created by the SO plugin supposed to be referencable in EnvInject configuration? So far I have to return to SetEnv/ToolEnvironment because EnvInject cannot replace the functionality that combi provides. What I am trying to do is get tool paths in the PATH for jobs we run (i.e. an Ant job). Thanks for looking into it.

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          src/main/java/org/jenkinsci/plugins/sharedobjects/ToolInstallationJobProperty.java
          http://jenkins-ci.org/commit/shared-objects-plugin/e325d7655dde80483e8ea485090a36a24a38e773
          Log:
          Fix JENKINS-12879

          Compare: https://github.com/jenkinsci/shared-objects-plugin/compare/9bcb614...e325d76

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/org/jenkinsci/plugins/sharedobjects/ToolInstallationJobProperty.java http://jenkins-ci.org/commit/shared-objects-plugin/e325d7655dde80483e8ea485090a36a24a38e773 Log: Fix JENKINS-12879 Compare: https://github.com/jenkinsci/shared-objects-plugin/compare/9bcb614...e325d76

          There was an issue when the tool name contains a space or a dash.
          I fixed it: in the above cases, the space and dash characters are replaced by an underscore.
          And in the 'Prepare environment' section, if you check 'Populate tools installations', the tool locations are populated as environment variables.

          Gregory Boissinot added a comment - There was an issue when the tool name contains a space or a dash. I fixed it: in the above cases, the space and dash characters are replaced by an underscore. And in the 'Prepare environment' section, if you check 'Populate tools installations', the tool locations are populated as environment variables.

            gbois Gregory Boissinot
            f_zschocke Florian Zschocke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: