• Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Critical Critical
    • None
    • 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

      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 
      
      

       

          [JENKINS-59892] Token evaluation fails in GitPlugin

          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.

          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.

          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. 

           

          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.   

          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?

          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 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

          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

          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.

          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 added a comment -

          Moshe Zvi added a comment - It happened a few months ago: https://github.com/jenkinsci/build-name-setter-plugin/issues/39

          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?

          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 added a comment -

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

          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.

          Mark Waite added a comment -

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

          Mark Waite added a comment - Are you able to install build-name-setter 1.7.1 to see if that resolves the issue?

          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?

          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?

          Mark Waite added a comment -

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

          Mark Waite added a comment - Yes, that was my idea to test if that is the crucial change that resolves your issue.

          Moshe Zvi added a comment -

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

          Moshe Zvi added a comment - OK. I'll find some time to install the plugin.

          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

          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

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

          Damian Szczepanik added a comment - Resolving as it works as expected when the configuration is not correct

          Moshe Zvi added a comment -

          dszczepanik: 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.

          Moshe Zvi added a comment - dszczepanik : 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.

          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

          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

          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 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.

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

              Created:
              Updated:
              Resolved: