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

Token evaluation fails in GitPlugin

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Cannot Reproduce
    • Labels:
      None
    • Environment:
      Jenkins 2.176.3, Ubuntu 14.04
      Environment Injector Plugin - 2.2.1
      Build Name and Description Setter - 2.0.3
      GitPlugin - 3.12.1
      GitClient Plugin - 2.9.0
      TokenMacroPlugin 2.8
    • Similar Issues:

      Description

      We use a macro (${PACKAGE_VERSION}) to push a tag to git after a successful build. 

      This used to work, until we started getting this error:

      ...
      [EnvInject] - Injecting environment variables from a build step.
      [EnvInject] - Injecting as environment variables the properties file path 'build.properties'
      [EnvInject] - Variables injected successfully.
      Failed to evaluate name macro:org.jenkinsci.plugins.tokenmacro.MacroEvaluationException: Unrecognized macro 'PACKAGE_VERSION' in '#59 (***-${PACKAGE_VERSION})'
      Archiving artifacts 
      
      

       

        Attachments

          Activity

          moshe_zvi Moshe Zvi created issue -
          Hide
          markewaite Mark Waite added a comment -

          What was the last version where it worked?

          The 4.0.0-rc release is a deprecated version with known security issues (SECURITY-1534). Have you tried either updating to the latest pre-releases (git client plugin 3.0.0-beta12 and git plugin 4.0.0-beta12) or downgrading to the most recent production releases (git client plugin 2.9.0 and git plugin 3.12.1)?

          Is the failing job a Freestyle job, a Pipeline job, a Multibranch Pipeline job, or some other type of job?

          Based on the log message, it appears you're reading environment variables from a file named 'build.properties'. Is that correct?

          Please provide more details so that others can duplicate the problem you're seeing.

          Show
          markewaite Mark Waite added a comment - What was the last version where it worked? The 4.0.0-rc release is a deprecated version with known security issues ( SECURITY-1534 ). Have you tried either updating to the latest pre-releases ( git client plugin 3.0.0-beta12 and git plugin 4.0.0-beta12 ) or downgrading to the most recent production releases ( git client plugin 2.9.0 and git plugin 3.12.1 )? Is the failing job a Freestyle job, a Pipeline job, a Multibranch Pipeline job, or some other type of job? Based on the log message, it appears you're reading environment variables from a file named 'build.properties'. Is that correct? Please provide more details so that others can duplicate the problem you're seeing.
          markewaite Mark Waite made changes -
          Field Original Value New Value
          Assignee Mark Waite [ markewaite ]
          Hide
          moshe_zvi Moshe Zvi added a comment -

          The job is a freestyle job, and I've just confirmed this reproduces with git plugin 3.9.1 and 3.12.1. 

          The GitClientPlugin version is 3.0.0-rc - I'll try downgrading that as well. 

          As for the properties file: I've confirmed it's there and the property is updated. The EnvInject plugin seems to be working properly, but perhaps the interaction with the TokenMacro is incorrect?

          Let me know if you need more info, I appreciate you looking into this. 

           

          Show
          moshe_zvi Moshe Zvi added a comment - The job is a freestyle job, and I've just confirmed this reproduces with git plugin 3.9.1 and 3.12.1.  The GitClientPlugin version is 3.0.0-rc - I'll try downgrading that as well.  As for the properties file: I've confirmed it's there and the property is updated. The EnvInject plugin seems to be working properly, but perhaps the interaction with the TokenMacro is incorrect? Let me know if you need more info, I appreciate you looking into this.   
          Hide
          markewaite Mark Waite added a comment -

          Please provide the job definition that is showing the problem. The config.xml file will show where the token macro replacement is being attempted in the job and may help identify the last version where it worked.

          Any idea which version is the last one that was known to work?

          Show
          markewaite Mark Waite added a comment - Please provide the job definition that is showing the problem. The config.xml file will show where the token macro replacement is being attempted in the job and may help identify the last version where it worked. Any idea which version is the last one that was known to work?
          moshe_zvi Moshe Zvi made changes -
          Attachment config.xml [ 49238 ]
          Hide
          moshe_zvi Moshe Zvi added a comment -

          The same job was working fine earlier today. It just stopped (no changes to the environment).

          [EnvInject] - Injecting environment variables from a build step.
          [EnvInject] - Injecting as environment variables the properties file path 'build.properties'
          [EnvInject] - Variables injected successfully.
          New run name is '#56 (adallomauthgateway-0.161.54)'
          Archiving artifacts
          using credential mcasjen_vsts_token
           > git tag -l adallomauthgateway-0.161.54 # timeout=10
           > git tag -a -f -m NO_BUILD adallomauthgateway-0.161.54 # timeout=10
          Pushing tag adallomauthgateway-0.161.54 to repo origin 

          However, it seems like there's actually a problem with EnvInjector: the file is there, and the content is correct, but apparently the injection to the environment doesn't work, since the variables aren't accessible. 

          [EnvInject] - Injecting environment variables from a build step.
          [EnvInject] - Injecting as environment variables the properties file path 'build.properties'
          [EnvInject] - Variables injected successfully.
          [authgateway-iteration-161] $ /bin/bash -xe /tmp/****192125430079668331.sh
          + cat build.properties
          VERSION=0.161.66
          PACKAGE_VERSION=0.161.66
          major=0.161
          MAJOR_RELEASE=0.161
          build_number=69
          git_commit=3f4fe1ae90808638a1c3008c4db55bdf81dee182
          git_branch=origin/iterations/iteration-161
          WEBALLOM_VERSION=0.161.60
          + echo PACKAGE_VERSION=
          PACKAGE_VERSION= 
          Failed to evaluate name macro:org.****ci.plugins.tokenmacro.MacroEvaluationException: Unrecognized macro 'PACKAGE_VERSION' in '#69 (adallomauthgateway-${PACKAGE_VERSION})'
          Archiving artifacts
          using credential XXX
           > git tag -l authgateway-${PACKAGE_VERSION} # timeout=10
           > git tag -a -f -m Jenkins Git plugin tagging with authgateway-${PACKAGE_VERSION} authgateway-${PACKAGE_VERSION} # timeout=10
          Pushing tag authgateway-${PACKAGE_VERSION} to repo origin
           > git --version # timeout=10
          using GIT_ASKPASS to set credentials XXX
           > git push XXX authgateway-${PACKAGE_VERSION}
          ERROR: Failed to push tag authgateway-${PACKAGE_VERSION} to origin
          hudson.plugins.git.GitException: Command "git push XXX authgateway-${PACKAGE_VERSION}" returned status code 1:
          stdout: 
          stderr: To XXX
           ! [rejected]        authgateway-${PACKAGE_VERSION} -> authgateway-${PACKAGE_VERSION} (already exists)
          error: failed to push some refs to 'XXX'
          

          Could it actually be a problem with setting the build name that causes the error? config.xml

          Show
          moshe_zvi Moshe Zvi added a comment - The same job was working fine earlier today. It just stopped (no changes to the environment). [EnvInject] - Injecting environment variables from a build step. [EnvInject] - Injecting as environment variables the properties file path 'build.properties' [EnvInject] - Variables injected successfully. New run name is '#56 (adallomauthgateway-0.161.54)' Archiving artifacts using credential mcasjen_vsts_token > git tag -l adallomauthgateway-0.161.54 # timeout=10 > git tag -a -f -m NO_BUILD adallomauthgateway-0.161.54 # timeout=10 Pushing tag adallomauthgateway-0.161.54 to repo origin However, it seems like there's actually a problem with EnvInjector: the file is there, and the content is correct, but apparently the injection to the environment doesn't work, since the variables aren't accessible.  [EnvInject] - Injecting environment variables from a build step. [EnvInject] - Injecting as environment variables the properties file path 'build.properties' [EnvInject] - Variables injected successfully. [authgateway-iteration-161] $ /bin/bash -xe /tmp/****192125430079668331.sh + cat build.properties VERSION=0.161.66 PACKAGE_VERSION=0.161.66 major=0.161 MAJOR_RELEASE=0.161 build_number=69 git_commit=3f4fe1ae90808638a1c3008c4db55bdf81dee182 git_branch=origin/iterations/iteration-161 WEBALLOM_VERSION=0.161.60 + echo PACKAGE_VERSION= PACKAGE_VERSION= Failed to evaluate name macro:org.****ci.plugins.tokenmacro.MacroEvaluationException: Unrecognized macro 'PACKAGE_VERSION' in '#69 (adallomauthgateway-${PACKAGE_VERSION})' Archiving artifacts using credential XXX > git tag -l authgateway-${PACKAGE_VERSION} # timeout=10 > git tag -a -f -m Jenkins Git plugin tagging with authgateway-${PACKAGE_VERSION} authgateway-${PACKAGE_VERSION} # timeout=10 Pushing tag authgateway-${PACKAGE_VERSION} to repo origin > git --version # timeout=10 using GIT_ASKPASS to set credentials XXX > git push XXX authgateway-${PACKAGE_VERSION} ERROR: Failed to push tag authgateway-${PACKAGE_VERSION} to origin hudson.plugins.git.GitException: Command "git push XXX authgateway-${PACKAGE_VERSION}" returned status code 1: stdout: stderr: To XXX ! [rejected] authgateway-${PACKAGE_VERSION} -> authgateway-${PACKAGE_VERSION} (already exists) error: failed to push some refs to 'XXX' Could it actually be a problem with setting the build name that causes the error? config.xml
          markewaite Mark Waite made changes -
          Component/s envinject-plugin [ 15893 ]
          Hide
          markewaite Mark Waite added a comment - - edited

          Could it actually be a problem with setting the build name that causes the error?

          I would be very surprised if setting the build name were causing the problem. However, it could be, just seems unlikely.

          Show
          markewaite Mark Waite added a comment - - edited Could it actually be a problem with setting the build name that causes the error? I would be very surprised if setting the build name were causing the problem. However, it could be, just seems unlikely.
          moshe_zvi Moshe Zvi made changes -
          Environment Jenkins 2.176.3, Ubuntu 14.04
          GitPlugin 4.0.0-rc
          TokenMacroPlugin 2.8
          Jenkins 2.176.3, Ubuntu 14.04
          Environment Injector Plugin - 2.2.1
          GitPlugin - 3.12.1
          GitClient Plugin - 2.9.0
          TokenMacroPlugin 2.8
          Hide
          moshe_zvi Moshe Zvi added a comment -
          Show
          moshe_zvi Moshe Zvi added a comment - It happened a few months ago: https://github.com/jenkinsci/build-name-setter-plugin/issues/39
          markewaite Mark Waite made changes -
          Component/s git-plugin [ 15543 ]
          markewaite Mark Waite made changes -
          Component/s build-name-setter-plugin [ 15902 ]
          markewaite Mark Waite made changes -
          Assignee Damian Szczepanik [ dszczepanik ]
          Hide
          markewaite Mark Waite added a comment -

          Thanks. That issue is listed as resolved in May 2019. Are you using a version that was released before May 2019?

          Show
          markewaite Mark Waite added a comment - Thanks. That issue is listed as resolved in May 2019. Are you using a version that was released before May 2019?
          moshe_zvi Moshe Zvi made changes -
          Environment Jenkins 2.176.3, Ubuntu 14.04
          Environment Injector Plugin - 2.2.1
          GitPlugin - 3.12.1
          GitClient Plugin - 2.9.0
          TokenMacroPlugin 2.8
          Jenkins 2.176.3, Ubuntu 14.04
          Environment Injector Plugin - 2.2.1
          Build Name and Description Setter - 2.0.3
          GitPlugin - 3.12.1
          GitClient Plugin - 2.9.0
          TokenMacroPlugin 2.8
          Hide
          moshe_zvi Moshe Zvi added a comment -

          I'm using the latest available version: 2.0.3. To the best of my knowledge, it was released in September.

          Show
          moshe_zvi Moshe Zvi added a comment - I'm using the latest available version: 2.0.3. To the best of my knowledge, it was released in September.
          Hide
          markewaite Mark Waite added a comment -

          Are you able to install build-name-setter 1.7.1 to see if that resolves the issue?

          Show
          markewaite Mark Waite added a comment - Are you able to install build-name-setter 1.7.1 to see if that resolves the issue?
          Hide
          moshe_zvi Moshe Zvi added a comment -

          I'll give it a try.
          So basically, revert to the last version before the breaking change in 2.0?

          Show
          moshe_zvi Moshe Zvi added a comment - I'll give it a try. So basically, revert to the last version before the breaking change in 2.0?
          Hide
          markewaite Mark Waite added a comment -

          Yes, that was my idea to test if that is the crucial change that resolves your issue.

          Show
          markewaite Mark Waite added a comment - Yes, that was my idea to test if that is the crucial change that resolves your issue.
          Hide
          moshe_zvi Moshe Zvi added a comment -

          OK. I'll find some time to install the plugin.

          Show
          moshe_zvi Moshe Zvi added a comment - OK. I'll find some time to install the plugin.
          Hide
          dszczepanik Damian Szczepanik added a comment -

          Based on logs it is clear to me that the build configuration is not correct and this is why macro plugin reports the issue which might be passed over via other plugin.

          Fix the configuration first

          Show
          dszczepanik Damian Szczepanik added a comment - Based on logs it is clear to me that the build configuration is not correct and this is why macro plugin reports the issue which might be passed over via other plugin. Fix the configuration first
          Hide
          dszczepanik Damian Szczepanik added a comment -

          Resolving as it works as expected when the configuration is not correct

          Show
          dszczepanik Damian Szczepanik added a comment - Resolving as it works as expected when the configuration is not correct
          dszczepanik Damian Szczepanik made changes -
          Resolution Cannot Reproduce [ 5 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Hide
          moshe_zvi Moshe Zvi added a comment -

          Damian Szczepanik: How is "clear to you" that the configuration is incorrect? This configuration was working correctly, and suddenly stopped.
          If you want to close the issue, at least provide some info on how to fix the configuration.

          Show
          moshe_zvi Moshe Zvi added a comment - Damian Szczepanik : How is "clear to you" that the configuration is incorrect? This configuration was working correctly, and suddenly stopped. If you want to close the issue, at least provide some info on how to fix the configuration.
          Hide
          dszczepanik Damian Szczepanik added a comment -

          First, you need to prove this error comes from my plugin - you use the same macro a few times for different plugins and I have checked - this one works for me with plugin I develop. Second you are trying to evaluate empty string:
          + echo PACKAGE_VERSION=
          PACKAGE_VERSION=

          and error says that this is not valid operation. If you analyze output carefully you will notice that the cause of build failure is probably here:

          ERROR: Failed to push tag authgateway-${PACKAGE_VERSION} to origin
          hudson.plugins.git.GitException: Command "git push XXX authgateway-${PACKAGE_VERSION}" returned

          Show
          dszczepanik Damian Szczepanik added a comment - First, you need to prove this error comes from my plugin - you use the same macro a few times for different plugins and I have checked - this one works for me with plugin I develop. Second you are trying to evaluate empty string: + echo PACKAGE_VERSION= PACKAGE_VERSION= and error says that this is not valid operation. If you analyze output carefully you will notice that the cause of build failure is probably here: ERROR: Failed to push tag authgateway-${PACKAGE_VERSION} to origin hudson.plugins.git.GitException: Command "git push XXX authgateway-${PACKAGE_VERSION}" returned
          Hide
          moshe_zvi Moshe Zvi added a comment -

          However, the EnvInject plugin is misbehaving, because - as you can plainly see - the content of the file is fine. So I'm guessing an EnvInject issue.
          I don't which plugin is yours, but the issue is very much still happening, so please refrain from closing it until we've had a chance to fully examine and resolve.

          Show
          moshe_zvi Moshe Zvi added a comment - However, the EnvInject plugin is misbehaving, because - as you can plainly see - the content of the file is fine. So I'm guessing an EnvInject issue. I don't which plugin is yours, but the issue is very much still happening, so please refrain from closing it until we've had a chance to fully examine and resolve.
          moshe_zvi Moshe Zvi made changes -
          Resolution Cannot Reproduce [ 5 ]
          Status Resolved [ 5 ] In Review [ 10005 ]
          moshe_zvi Moshe Zvi made changes -
          Status In Review [ 10005 ] In Progress [ 3 ]
          moshe_zvi Moshe Zvi made changes -
          Status In Progress [ 3 ] In Review [ 10005 ]
          moshe_zvi Moshe Zvi made changes -
          Resolution Cannot Reproduce [ 5 ]
          Status In Review [ 10005 ] Resolved [ 5 ]

            People

            Assignee:
            dszczepanik Damian Szczepanik
            Reporter:
            moshe_zvi Moshe Zvi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: