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

EnvInject plug-in does not read ${WORKSPACE} property

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • envinject-plugin
    • None
    • Jenkins v1.458 on Linux (CentOS v5.6)
      EnvInject v1.45

      In the EnvInject plug-in configuration for a job, both the "Keep Jenkins Environment Variables" and "Keep Jenkins Build Variables" check-boxes are selected.

      The "Properties Content" section sets the following property:

      M2_REPO = ${WORKSPACE}/.repository

      However, when a build runs, the log reports:

      [EnvInject] - Loading node environment variables.
      [EnvInject] - Preparing an environment for the build.
      [EnvInject] - Keep Jenkins system variables.
      [EnvInject] - Keep Jenkins build variables.
      [EnvInject] - Injecting as environment variables the properties content
      M2_REPO=${WORKSPACE}/.repository

      [EnvInject] - Variables injected successfully.
      [EnvInject] - Unset unresolved 'M2_REPO' variable.

      and the build operates as if the environment variable is unset. The ${WORKSPACE} property appears to be ignored.

          [JENKINS-13396] EnvInject plug-in does not read ${WORKSPACE} property

          Gregory Boissinot added a comment - - edited

          In the 'prepare environment' section, WORKSPACE variable is not available because you are running before a SCM checkout.
          The SCM checkout is supposed to create the workspace.
          For your use case, you have to put your Properties content in 'Build Environment'>Inject environment variables to the build process section: this section runs after the SCM checkout, therefore the workspace directory is always created and you access without problem to the WORKSPACE variable.

          In the next releases, I'll add more comments in help message about this subject.

          Gregory Boissinot added a comment - - edited In the 'prepare environment' section, WORKSPACE variable is not available because you are running before a SCM checkout. The SCM checkout is supposed to create the workspace. For your use case, you have to put your Properties content in 'Build Environment'>Inject environment variables to the build process section: this section runs after the SCM checkout, therefore the workspace directory is always created and you access without problem to the WORKSPACE variable. In the next releases, I'll add more comments in help message about this subject.

          John Bayley added a comment -

          Thanks for the speedy reply. I didn't look for the existence of the "Inject environment variables to the build process" check-box after selecting the preceding "Prepare an environment for the run" check-box. Now I know!

          John Bayley added a comment - Thanks for the speedy reply. I didn't look for the existence of the "Inject environment variables to the build process" check-box after selecting the preceding "Prepare an environment for the run" check-box. Now I know!

            gbois Gregory Boissinot
            jaybee John Bayley
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: