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

Missing git variables from the per-job "Environment Variables" page

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • git-plugin
    • None
    • Windows Server 2012 R2 Standard 64bit
      jenkins 2.107.1
      git-plugin 3.8.0
      dsl generated freestyle-job

      After a build there are no git-Variables like GIT_BRANCH or GIT_REVISION in the list of environment variables.

        1. gitBuildData.PNG
          gitBuildData.PNG
          41 kB
        2. envVars2.PNG
          envVars2.PNG
          50 kB
        3. envVars.PNG
          envVars.PNG
          54 kB
        4. config.PNG
          config.PNG
          54 kB

          [JENKINS-50369] Missing git variables from the per-job "Environment Variables" page

          Mark Waite added a comment -

          Please provide more details so that others can duplicate the bug. I attempted to duplicate the bug with the following steps:

          1. Create a freestyle job that uses a git repository and reports the environment variables after checkout
          2. Run that freestyle job
          3. Confirm the environment variables are reported

          More details are in the commit message for the job that performs that check.

          I see the environment variables output for my job as:

            GIT_AUTHOR_EMAIL=mwaite@mark-pc2.markwaite.net
            GIT_AUTHOR_NAME=Jenkins Docker User
            GIT_BRANCH=origin/master
            GIT_COMMIT=42fbc34cc227fd1514710d54e790cb6489c20282
            GIT_COMMITTER_EMAIL=mwaite@mark-pc2.markwaite.net
            GIT_COMMITTER_NAME=Jenkins Docker User
            GIT_PREVIOUS_COMMIT=42fbc34cc227fd1514710d54e790cb6489c20282
            GIT_URL=https://github.com/jenkinsci/git-client-plugin
          

          Please provide more details to duplicate the problem you're seeing. I don't know how the job looks after DSL generates a freestyle job.

          Mark Waite added a comment - Please provide more details so that others can duplicate the bug. I attempted to duplicate the bug with the following steps: Create a freestyle job that uses a git repository and reports the environment variables after checkout Run that freestyle job Confirm the environment variables are reported More details are in the commit message for the job that performs that check. I see the environment variables output for my job as: GIT_AUTHOR_EMAIL=mwaite@mark-pc2.markwaite.net GIT_AUTHOR_NAME=Jenkins Docker User GIT_BRANCH=origin/master GIT_COMMIT=42fbc34cc227fd1514710d54e790cb6489c20282 GIT_COMMITTER_EMAIL=mwaite@mark-pc2.markwaite.net GIT_COMMITTER_NAME=Jenkins Docker User GIT_PREVIOUS_COMMIT=42fbc34cc227fd1514710d54e790cb6489c20282 GIT_URL=https://github.com/jenkinsci/git-client-plugin Please provide more details to duplicate the problem you're seeing. I don't know how the job looks after DSL generates a freestyle job.

          Tim Schlüter added a comment -

          I tested as you did it (New Freestyle Job(by hand), only a git repo, ...) and the git-variables are still missing.

          What can I do to provide you more information?

          Tim Schlüter added a comment - I tested as you did it (New Freestyle Job(by hand), only a git repo, ...) and the git-variables are still missing. What can I do to provide you more information?

          Mark Waite added a comment -

          The picture of the environment variables screen was the key item. I've never used that page to see the environment variables which were set during the job.

          The git plugin injects environment variables into the job but does not inject them in such a way that they are visible in that page. My example job shows that the environment variables are set by the plugin and are usable by "bat", "shell" and "cross-platform shell" steps. However, my "Environment Variables" page for each job does not show those variables.

          Since the URL to that environment variables page is called "injectedEnvVars", I assume the git plugin is adding environment variables to the job by a different technique than other plugins.

          Can you describe your use case more deeply? Are you reading the values of those environment variables from a program later?

          Mark Waite added a comment - The picture of the environment variables screen was the key item. I've never used that page to see the environment variables which were set during the job. The git plugin injects environment variables into the job but does not inject them in such a way that they are visible in that page. My example job shows that the environment variables are set by the plugin and are usable by "bat", "shell" and "cross-platform shell" steps. However, my "Environment Variables" page for each job does not show those variables. Since the URL to that environment variables page is called "injectedEnvVars", I assume the git plugin is adding environment variables to the job by a different technique than other plugins. Can you describe your use case more deeply? Are you reading the values of those environment variables from a program later?

          Tim Schlüter added a comment - - edited

          It was because my job-sciprt shows that the variables were empty, so I was looking for the list to check if they where set, because in the past they where listed

          But in the now it shows that I access the variables wrong. Every thing works as expected, except of the view as you find out.

          If I change jobs and something went wrong with variables this is one of my first point to look at.

          Tim Schlüter added a comment - - edited It was because my job-sciprt shows that the variables were empty, so I was looking for the list to check if they where set, because in the past they where listed But in the now it shows that I access the variables wrong. Every thing works as expected, except of the view as you find out. If I change jobs and something went wrong with variables this is one of my first point to look at.

          Mark Waite added a comment -

          Any idea when the last version was that showed those environment variables in that page?

          I'm not aware of any changes in the git plugin that would result in such a change in the environment variables page.

          Mark Waite added a comment - Any idea when the last version was that showed those environment variables in that page? I'm not aware of any changes in the git plugin that would result in such a change in the environment variables page.

          Tim Schlüter added a comment - - edited

          I found that the different is the build-step 'Inject environment variables' cause the git variables to show appear on the list.

          Tim Schlüter added a comment - - edited I found that the different is the build-step 'Inject environment variables' cause the git variables to show appear on the list.

          Mark Waite added a comment -

          Thanks for the investigation!

          Mark Waite added a comment - Thanks for the investigation!

            Unassigned Unassigned
            timsch Tim Schlüter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: