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

GitHub Commit Status Setter - Cannot retrieve Git metadata

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Upon upgrading a number of plugins on one of our Jenkins clusters, we observed that builds were failing with the following exceptions:

       

      ERROR: [GitHub Commit Status Setter] - Cannot retrieve Git metadata for the build, setting build result to UNSTABLE
      

       

      Rolling the `GitHub` plugin back from '1.29.3' to '1.29.2' removes the error and builds now function as expected. 

        Attachments

          Activity

          Hide
          bgaillard Baptiste Gaillard added a comment -

          Oleksandr Stovbenko thanks for the suggestions, I already tried this few months ago without success.

          Today I tried to update the https://github.com/jenkinsci/github-plugin to find the problem and fix it.

          It seems that the problem came from the fact that the https://github.com/jenkinsci/git-plugin replaced the BuildData class by the BuildDetails class (this is explained here https://github.com/jenkinsci/git-plugin/commit/07cfa5ddef698838b01d4214915f98d4e902c0f8#diff-6cb4dc50342af417dc66c68b45c48fb1).

          As a result when Jenkins run a job the Github plugin failed to get the last build (to then retrieve the revision SHA1). 

          For now I just implemented VERY UGLY updates (i'll take the time to propose a clean PR later), the repo is here https://github.com/bgaillard/github-plugin.

          If you would like to test it compile it with mvn install -Dmaven.test.skip=true (I did not took time to fix the tests).

          Show
          bgaillard Baptiste Gaillard added a comment - Oleksandr Stovbenko thanks for the suggestions, I already tried this few months ago without success. Today I tried to update the  https://github.com/jenkinsci/github-plugin  to find the problem and fix it. It seems that the problem came from the fact that the  https://github.com/jenkinsci/git-plugin  replaced the BuildData class by the BuildDetails class (this is explained here https://github.com/jenkinsci/git-plugin/commit/07cfa5ddef698838b01d4214915f98d4e902c0f8#diff-6cb4dc50342af417dc66c68b45c48fb1 ). As a result when Jenkins run a job the Github plugin failed to get the last build (to then retrieve the revision SHA1).  For now I just implemented VERY UGLY updates (i'll take the time to propose a clean PR later), the repo is here  https://github.com/bgaillard/github-plugin . If you would like to test it compile it with mvn install -Dmaven.test.skip=true (I did not took time to fix the tests).
          Hide
          bgaillard Baptiste Gaillard added a comment -

          For those who do not want to compile the project from my fork you can find the HPI file here https://github.com/bgaillard/github-plugin/releases/tag/v1.30.0-alpha-1 and install it manually in Jenkins.

          Hope this helps.

          Show
          bgaillard Baptiste Gaillard added a comment - For those who do not want to compile the project from my fork you can find the HPI file here  https://github.com/bgaillard/github-plugin/releases/tag/v1.30.0-alpha-1  and install it manually in Jenkins. Hope this helps.
          Hide
          bgaillard Baptiste Gaillard added a comment - - edited

          Hi, I created a PR on the github plugin project here https://github.com/jenkinsci/github-plugin/pull/216. Hope this one will be reviewed and accepted quickly

          Show
          bgaillard Baptiste Gaillard added a comment - - edited Hi, I created a PR on the github plugin project here  https://github.com/jenkinsci/github-plugin/pull/216 . Hope this one will be reviewed and accepted quickly
          Hide
          jcarsique Julien Carsique added a comment -

          Baptiste Gaillard Thank you! However, this ticket is missing a stack trace for accuracy. The PR you submitted does not match our current install while we do have the same/similar issue.

          As I wrote in the PR thread: we're encountering the same issue symptom with lower plugin versions (see https://jira.nuxeo.com/browse/NXBT-2867).
          Our current versions are:

          • CloudBees Jenkins Enterprise 2.164.3.2-rolling
          • Git client plugin 2.7.6
          • Git plugin 3.9.3
          • SCM API Plugin 2.4.0

          What is your stacktrace and reproduction case please? Is it the same?

            java.io.IOException: Cannot retrieve Git metadata for the build
            	at org.jenkinsci.plugins.github.util.BuildDataHelper.getCommitSHA1(BuildDataHelper.java:87)
            	at org.jenkinsci.plugins.github.status.sources.BuildDataRevisionShaSource.get(BuildDataRevisionShaSource.java:32)
            	at org.jenkinsci.plugins.github.status.GitHubCommitStatusSetter.perform(GitHubCommitStatusSetter.java:135)
            Caused: org.jenkinsci.plugins.github.common.CombineErrorHandler$ErrorHandlingException
            	at org.jenkinsci.plugins.github.common.CombineErrorHandler.handle(CombineErrorHandler.java:74)
            	at org.jenkinsci.plugins.github.status.GitHubCommitStatusSetter.perform(GitHubCommitStatusSetter.java:164)
            	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
            	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
            	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
            	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            	at java.lang.Thread.run(Thread.java:748)

          when running

              step([$class: 'GitHubCommitStatusSetter', reposSource: [$class: 'ManuallyEnteredRepositorySource', url: repos_url],
                  contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: '...'],
                  statusResultSource: [$class: 'ConditionalStatusResultSource',
                      results: [[$class: 'AnyBuildResult', message: status_msg.get(status), state: status]]]]) 
          Show
          jcarsique Julien Carsique added a comment - Baptiste Gaillard Thank you! However, this ticket is missing a stack trace for accuracy. The PR you submitted does not match our current install while we do have the same/similar issue. As I wrote in the PR thread: we're encountering the same issue symptom with lower plugin versions (see https://jira.nuxeo.com/browse/NXBT-2867 ). Our current versions are: CloudBees Jenkins Enterprise 2.164.3.2-rolling Git client plugin 2.7.6 Git plugin 3.9.3 SCM API Plugin 2.4.0 What is your stacktrace and reproduction case please? Is it the same? java.io.IOException: Cannot retrieve Git metadata for the build at org.jenkinsci.plugins.github.util.BuildDataHelper.getCommitSHA1(BuildDataHelper.java:87) at org.jenkinsci.plugins.github.status.sources.BuildDataRevisionShaSource.get(BuildDataRevisionShaSource.java:32) at org.jenkinsci.plugins.github.status.GitHubCommitStatusSetter.perform(GitHubCommitStatusSetter.java:135) Caused: org.jenkinsci.plugins.github.common.CombineErrorHandler$ErrorHandlingException at org.jenkinsci.plugins.github.common.CombineErrorHandler.handle(CombineErrorHandler.java:74) at org.jenkinsci.plugins.github.status.GitHubCommitStatusSetter.perform(GitHubCommitStatusSetter.java:164) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748) when running step([$class: 'GitHubCommitStatusSetter' , reposSource: [$class: 'ManuallyEnteredRepositorySource' , url: repos_url], contextSource: [$class: 'ManuallyEnteredCommitContextSource' , context: '...' ], statusResultSource: [$class: 'ConditionalStatusResultSource' , results: [[$class: 'AnyBuildResult' , message: status_msg.get(status), state: status]]]])
          Hide
          bgaillard Baptiste Gaillard added a comment - - edited

           Hi Julien Carsique, no need to provide a Stack Trace in my case.

          I explained the problem in my previous comment, in our case the problem is caused by the version 4.0.x of the Jenkins git-plugin. 

          It seems that your Exception is thown at the same place than our, in our case at line L78] the method returns an empty list.

          As a result at L82] the buildData returned is null and then at L87] an IOException is thrown.

          The problem in our case is that the git-plugin does not create BuildData objects since version 4.0.x, instead it creates instances of class BuildDetails. So using build.getActions(BuildData.class) does not work, I used build.getActions(BuildDetails.class) instead at L78] and adapted the code in consequence to fix the problem.

          I think you can try to debug the problem as I did. What your can do is to update the Github Plugin by adding a logger and logging the class names of the actions you'll receive when calling https://javadoc.jenkins-ci.org/hudson/model/Actionable.html#getActions-- at the beginning of the getCommitSHA1 function.

          Their are chances you have an Action describing your build which is not of same class as the BuildData class and that's why its not working as expected.

          Let me know if you tried to fix the problem and what is the class name of your action in your case. 

          Hope this helps

          Show
          bgaillard Baptiste Gaillard added a comment - - edited  Hi Julien Carsique , no need to provide a Stack Trace in my case. I explained the problem in my previous comment, in our case the problem is caused by the version 4.0.x  of the Jenkins git-plugin.  It seems that your Exception is thown at the same place than our, in our case at line L78 ] the method returns an empty list. As a result at L82 ] the buildData  returned is null  and then at L87 ] an IOException  is thrown. The problem in our case is that the git-plugin does not create BuildData  objects since version 4.0.x , instead it creates instances of class BuildDetails . So using build.getActions(BuildData.class)  does not work, I used build.getActions(BuildDetails.class)  instead at  L78 ] and adapted the code in consequence to fix the problem. I think you can try to debug the problem as I did. What your can do is to update the Github Plugin by adding a logger and logging the class names of the actions you'll receive when calling https://javadoc.jenkins-ci.org/hudson/model/Actionable.html#getActions--  at the beginning of the getCommitSHA1  function. Their are chances you have an Action  describing your build which is not of same class as the BuildData  class and that's why its not working as expected. Let me know if you tried to fix the problem and what is the class name of your action in your case.  Hope this helps

            People

            • Assignee:
              lanwen Kirill Merkushev
              Reporter:
              fatmcgav Gavin Williams
            • Votes:
              18 Vote for this issue
              Watchers:
              31 Start watching this issue

              Dates

              • Created:
                Updated: