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

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

XMLWordPrintable

    • 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

       

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

              Created:
              Updated: