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

Getting string index out of range error when using git 2.16.2+

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • repo-plugin
    • None
    • Debian with git 2.16.2

      I have system running Debian with git 2.16.2.  REPO plugin fails to sync latest changes and throwing the following error:
      [devtools] $ git log --raw --first-parent --format="[[<as7d9m1R_MARK_A>]]%H[[<as7d9m1R_MARK_B>]%an[[<as7d9m1R_MARK_B>]%ae[[<as7d9m1R_MARK_B>]%aD[[<as7d9m1R_MARK_B>]%cn[[<as7d9m1R_MARK_B>]%ce[[<as7d9m1R_MARK_B>]%cD[[<as7d9m1R_MARK_B>]%s
      %b[[<as7d9m1R_MARK_B>]" b8630400d4ebf2406f49e11e213c9ae12cf7605b..a1e314337f062b4dd15beab1aaf1206af6183f2a
      FATAL: String index out of range: 38
      java.lang.StringIndexOutOfBoundsException: String index out of range: 38
      at java.lang.String.substring(String.java:1963)
      at hudson.plugins.repo.ChangeLog.generateChangeLog(ChangeLog.java:203)
      at hudson.plugins.repo.ChangeLog.saveChangeLog(ChangeLog.java:249)
      at hudson.plugins.repo.RepoScm.checkout(RepoScm.java:718)
      at hudson.scm.SCM.checkout(SCM.java:495)
      at hudson.model.AbstractProject.checkout(AbstractProject.java:1212)
      at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:566)
      at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:491)
      at hudson.model.Run.execute(Run.java:1737)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:421)
       

      However, on my other system (Ubuntu with git 1.9.1) it works as expected.  Upon further investigation I discovered git log output different between git versions 1.9.1 and 2.16.2:

      Here is output with git 1.9.1:

      /usr/local/bin/git log --raw --first-parent --format="[[<as7d9m1R_MARK_A>]]%H[[<as7d9m1R_MARK_B>]%an[[<as7d9m1R_MARK_B>]%ae[[<as7d9m1R_MARK_B>]%aD[[<as7d9m1R_MARK_B>]%cn[[<as7d9m1R_MARK_B>]%ce[[<as7d9m1R_MARK_B>]%cD[[<as7d9m1R_MARK_B>]%s%b[[<as7d9m1R_MARK_B>]" a1e314337f062b4dd15beab1aaf1206af6183f2a..e6164c7e256f19dc285377b33187b84dc7602a52 | more

      [[<as7d9m1R_MARK_A>]]e6164c7e256f19dc285377b33187b84dc7602a52[[<as7d9m1R_MARK_B>]Igor Sarki

      sov[[<as7d9m1R_MARK_B>]isarkisov@google.com[[<as7d9m1R_MARK_B>]Wed, 28 Feb 2018 18:03:08 -0

      800[[<as7d9m1R_MARK_B>]Igor Sarkisov[[<as7d9m1R_MARK_B>]isarkisov@google.com[[<as7d9m1R_MAR

      K_B>]Wed, 28 Feb 2018 18:03:08 -0800[[<as7d9m1R_MARK_B>]Adding function coverage support[[<

      as7d9m1R_MARK_B>]

       

      :000000 100644 0000000... 0d20b64... A  .gitignore

      Here is output with git 2.16.2:

      /usr/bin/git log --raw --first-parent --format="[[<as7d9m1R_MARK_A>]]%H[[<as7d9m1R_MARK_B>]%an[[<as7d9m1R_MARK_B>]%ae[[<as7d9m1R_MARK_B>]%aD[[<as7d9m1R_MARK_B>]%cn[[<as7d9m1R_MARK_B>]%ce[[<as7d9m1R_MARK_B>]%cD[[<as7d9m1R_MARK_B>]%s%b[[<as7d9m1R_MARK_B>]" a1e314337f062b4dd15beab1aaf1206af6183f2a..e6164c7e256f19dc285377b33187b84dc7602a52 | more

      [[<as7d9m1R_MARK_A>]]e6164c7e256f19dc285377b33187b84dc7602a52[[<as7d9m1R_MARK_B>]Igor Sarki

      sov[[<as7d9m1R_MARK_B>]isarkisov@google.com[[<as7d9m1R_MARK_B>]Wed, 28 Feb 2018 18:03:08 -0

      800[[<as7d9m1R_MARK_B>]Igor Sarkisov[[<as7d9m1R_MARK_B>]isarkisov@google.com[[<as7d9m1R_MAR

      K_B>]Wed, 28 Feb 2018 18:03:08 -0800[[<as7d9m1R_MARK_B>]Adding function coverage support[[<

      as7d9m1R_MARK_B>]

       

      :000000 100644 0000000 0d20b64 A        .gitignore

      --------------------------------

      As you can see outputs different between git versions, as a consequence I believe the following code is broken for git 2.16.2 (it tries to access string index at 38 and it git 2.16.2 it goes out of range):

      https://github.com/jenkinsci/repo-plugin/blob/8339a33e5085a515dcdefd004cce1fe6fd682d3f/src/main/java/hudson/plugins/repo/ChangeLog.java#L203

       

          [JENKINS-49829] Getting string index out of range error when using git 2.16.2+

          Dustin Oprea added a comment - - edited

          Affects me/us, too, but only happens periodically (every day or two, but dozens of successes in between).

           

          Dustin Oprea added a comment - - edited Affects me/us, too, but only happens periodically (every day or two, but dozens of successes in between).  

          AnneTheAgile added a comment -

          Am I missing something? The only difference is whether or not ellipses "..." appear, eg

          :000000 100644 0000000... 0d20b64... A  .gitignore

          Maybe since you have two git versions resident on the box you could force use the 'right' git version.

          AnneTheAgile added a comment - Am I missing something? The only difference is whether or not ellipses "..." appear, eg :000000 100644 0000000... 0d20b64... A  .gitignore Maybe since you have two git versions resident on the box you could force use the 'right' git version.

          Igor Sarkisov added a comment - - edited

          Are you suggesting we install git 1.9 on all our build machines and use that instead?  The better option is to add git 2.0+ support.  I can make pull request when I get some spare cycles.

          Igor Sarkisov added a comment - - edited Are you suggesting we install git 1.9 on all our build machines and use that instead?  The better option is to add git 2.0+ support.  I can make pull request when I get some spare cycles.

          This was triggered by the change in Git (v2.16.0-rc0~41^2~4) that Igor noticed[1].

          That said, this output was not made for machine parsing in the first place. Can Jenkins pass --no-abbrev-commit, or, better, use a more targeted command to obtain the information it needs (e.g. git rev-list or git diff-tree)?

          [1] commit ca69d4d5b14245c9ba4535212c4f4a0621e78ffa
          Author: Ann T Ropea <bedhanger@gmx.de>
          Date: Wed Dec 6 01:20:42 2017 +0100

          checkout: describe_detached_head: remove ellipsis after committish

          We do not want an ellipsis displayed following an (abbreviated) SHA-1
          value.

          The days when this was necessary to indicate the truncation to
          lower-level Git commands and/or the user are bygone.

          However, to ease the transition, the ellipsis will still be printed if
          the user sets the environment variable GIT_PRINT_SHA1_ELLIPSIS to "yes".

           

          Jonathan Nieder added a comment - This was triggered by the change in Git (v2.16.0-rc0~41^2~4) that Igor noticed [1] . That said, this output was not made for machine parsing in the first place. Can Jenkins pass --no-abbrev-commit, or, better, use a more targeted command to obtain the information it needs (e.g. git rev-list or git diff-tree)? [1]  commit ca69d4d5b14245c9ba4535212c4f4a0621e78ffa Author: Ann T Ropea <bedhanger@gmx.de> Date: Wed Dec 6 01:20:42 2017 +0100 checkout: describe_detached_head: remove ellipsis after committish We do not want an ellipsis displayed following an (abbreviated) SHA-1 value. The days when this was necessary to indicate the truncation to lower-level Git commands and/or the user are bygone. However, to ease the transition, the ellipsis will still be printed if the user sets the environment variable GIT_PRINT_SHA1_ELLIPSIS to "yes".  

          same happens with git 2.17.1:
          [Pipeline] End of Pipelinejava.lang.StringIndexOutOfBoundsException: String index out of range: -1
          at java.lang.String.substring(String.java:1931)
          at hudson.plugins.repo.ChangeLog.generateChangeLog(ChangeLog.java:204)
          at hudson.plugins.repo.ChangeLog.saveChangeLog(ChangeLog.java:249)
          at hudson.plugins.repo.RepoScm.checkout(RepoScm.java:718)
          at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:120)
          at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:90)
          at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:77)
          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)
          Finished: FAILURE

          Ilia Meerovich added a comment - same happens with git 2.17.1: [Pipeline] End of Pipelinejava.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1931) at hudson.plugins.repo.ChangeLog.generateChangeLog(ChangeLog.java:204) at hudson.plugins.repo.ChangeLog.saveChangeLog(ChangeLog.java:249) at hudson.plugins.repo.RepoScm.checkout(RepoScm.java:718) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:120) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:90) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:77) 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) Finished: FAILURE

          Ramaraj Bijur added a comment - - edited

          Same thing happens every alternative build triggers

          git --version
          git version 2.19.1

          [DEL_KAON_BCM_MIPS4K_LNUX_SKYNZ_01] $ git log --raw --first-parent --format="[[<as7d9m1R_MARK_A>]]%H[[<as7d9m1R_MARK_B>]%an[[<as7d9m1R_MARK_B>]%ae[[<as7d9m1R_MARK_B>]%aD[[<as7d9m1R_MARK_B>]%cn[[<as7d9m1R_MARK_B>]%ce[[<as7d9m1R_MARK_B>]%cD[[<as7d9m1R_MARK_B>]%s
          %b[[<as7d9m1R_MARK_B>]" ebe30a0bfeaa53175d236c26a6e6ca6981493826..76d334d856c3ee048b1688d33c0461e762afa9cd
          FATAL: String index out of range: 38
          java.lang.StringIndexOutOfBoundsException: String index out of range: 38
          at java.lang.String.substring(String.java:1963)
          at hudson.plugins.repo.ChangeLog.generateChangeLog(ChangeLog.java:203)
          at hudson.plugins.repo.ChangeLog.saveChangeLog(ChangeLog.java:249)
          at hudson.plugins.repo.RepoScm.checkout(RepoScm.java:718)
          at hudson.scm.SCM.checkout(SCM.java:504)
          at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
          at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
          at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
          at hudson.model.Run.execute(Run.java:1816)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:97)
          at hudson.model.Executor.run(Executor.java:429)

          Ramaraj Bijur added a comment - - edited Same thing happens every alternative build triggers git --version git version 2.19.1 [DEL_KAON_BCM_MIPS4K_LNUX_SKYNZ_01] $ git log --raw --first-parent --format="[ [<as7d9m1R_MARK_A>] ]%H[ [<as7d9m1R_MARK_B>] %an[ [<as7d9m1R_MARK_B>] %ae[ [<as7d9m1R_MARK_B>] %aD[ [<as7d9m1R_MARK_B>] %cn[ [<as7d9m1R_MARK_B>] %ce[ [<as7d9m1R_MARK_B>] %cD[ [<as7d9m1R_MARK_B>] %s %b[ [<as7d9m1R_MARK_B>] " ebe30a0bfeaa53175d236c26a6e6ca6981493826..76d334d856c3ee048b1688d33c0461e762afa9cd FATAL: String index out of range: 38 java.lang.StringIndexOutOfBoundsException: String index out of range: 38 at java.lang.String.substring(String.java:1963) at hudson.plugins.repo.ChangeLog.generateChangeLog(ChangeLog.java:203) at hudson.plugins.repo.ChangeLog.saveChangeLog(ChangeLog.java:249) at hudson.plugins.repo.RepoScm.checkout(RepoScm.java:718) at hudson.scm.SCM.checkout(SCM.java:504) at hudson.model.AbstractProject.checkout(AbstractProject.java:1208) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499) at hudson.model.Run.execute(Run.java:1816) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429)

          See https://issues.jenkins-ci.org/browse/JENKINS-49829?focusedCommentId=358623&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-358623: the problem has already been diagnosed, so additional reports of being affected are not necessary.

          Instead, what would help is a patch to fix it.

          Jonathan Nieder added a comment - See  https://issues.jenkins-ci.org/browse/JENKINS-49829?focusedCommentId=358623&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-358623: the problem has already been diagnosed, so additional reports of being affected are not necessary. Instead, what would help is a patch to fix it.

          yongqi niu added a comment -

          Is there any progress on this issue? I am also troubled by this problem

          yongqi niu added a comment - Is there any progress on this issue? I am also troubled by this problem

            Unassigned Unassigned
            isarkisov Igor Sarkisov
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: