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

EnvInject properties not consistently used for SCM

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • envinject-plugin
    • None

      Properties set in the job configuration can be used in the SCM configuration, but they do not appear to be applied to the 'Poll SCM' build trigger.

      In our environment, we specify the Perforce 'Client View Type' as 'View Map from File', and the file name depends on project parameters. When such a build is triggered manually, the parameters are applied. Here is the the first few lines of output from the 'Console Output' for a manual build.

      Started by user Travis Vitek
      [EnvInject] - Loading node environment variables.
      [EnvInject] - Preparing an environment for the build.
      [EnvInject] - Keeping Jenkins system variables.
      [EnvInject] - Keeping Jenkins build variables.
      [EnvInject] - Adding build parameters as variables.
      [EnvInject] - Injecting as environment variables the properties content 
      PROJECT_BRANCH=main
      PROJECT_NAME=tools
      
      [EnvInject] - Variables injected successfully.
      [EnvInject] - Injecting contributions.
      Building remotely on jayhawk in workspace /build/jenkins-slave/workspace/jenkins-test
      
      Deleting project workspace... Read ClientSpec from: //projects/main-tools.clientspec
      [jenkins-test] $ "C:\Program Files\Perforce\p4.exe" print -q //projects/main-tools.clientspec
      

      But when the the 'Poll SCM' build trigger is used, the parameters are not applied. Here is the output of the 'Perforce Polling Log'

      Started on Nov 28, 2012 11:17:51 AM
      Looking for changes...
      Using node: jayhawk
      Read ClientSpec from: //projects/${PROJECT_BRANCH}-${PROJECT_NAME}.clientspec
      [jenkins-slave] $ "C:\Program Files\Perforce\p4.exe" print -q //projects/${PROJECT_BRANCH}-${PROJECT_NAME}.clientspec
      

          [JENKINS-15963] EnvInject properties not consistently used for SCM

          Injected environment variables are only processed at build time. Therefore you can't use the future environment variables used to verify if the build has to be triggered.

          Gregory Boissinot added a comment - Injected environment variables are only processed at build time. Therefore you can't use the future environment variables used to verify if the build has to be triggered.

          Trevor Baker added a comment - - edited

          I don't know if this is still recent info, but it is suggested to use the "Masked Passwords" plugin for jobs that need to SCM poll.

          http://jenkins.361315.n4.nabble.com/Perforce-plugin-and-Globa-Password-from-EnvInject-tt4638553.html#a4638651

          Edit: I tried using "Masked Passwords" and the SCM plugin (perforce) failed in the poll with the same unresolved variable problem.

          Trevor Baker added a comment - - edited I don't know if this is still recent info, but it is suggested to use the "Masked Passwords" plugin for jobs that need to SCM poll. http://jenkins.361315.n4.nabble.com/Perforce-plugin-and-Globa-Password-from-EnvInject-tt4638553.html#a4638651 Edit: I tried using "Masked Passwords" and the SCM plugin (perforce) failed in the poll with the same unresolved variable problem.

          @Travis
          I'm afraid I can't fix this issue
          Environment variables are computed at build time and therefore they can't be used for the polling mechanism.
          However, the plugin that does the poll is able to retrieve previous environment variables

          @Trevor
          I'm afraid your comment doesn't match this issue.

          Gregory Boissinot added a comment - @Travis I'm afraid I can't fix this issue Environment variables are computed at build time and therefore they can't be used for the polling mechanism. However, the plugin that does the poll is able to retrieve previous environment variables @Trevor I'm afraid your comment doesn't match this issue.

          Trevor Baker added a comment -

          What is meant by "previous environment variables"?

          Trevor Baker added a comment - What is meant by "previous environment variables"?

          Injected environment variables from the previous build, meaning not the scheduled build. Therefore it the last build.

          Gregory Boissinot added a comment - Injected environment variables from the previous build, meaning not the scheduled build. Therefore it the last build.

            gbois Gregory Boissinot
            vitek Travis Vitek
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: