[JIRA] [git-client-plugin] (JENKINS-34309) git-client-plugin: StringIndexOutOfBoundsException when parsing branches

13 views
Skip to first unread message

frank@zerofudge.de (JIRA)

unread,
Apr 18, 2016, 6:14:02 AM4/18/16
to jenkinsc...@googlegroups.com
Frank Geusch created an issue
 
Jenkins / Bug JENKINS-34309
git-client-plugin: StringIndexOutOfBoundsException when parsing branches
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-client-plugin
Created: 2016/Apr/18 10:13 AM
Priority: Major Major
Reporter: Frank Geusch

we ran into this:

> git checkout -f a6ecfa813a4c9a5699df4ec39cfdd596852b8d71 # timeout=10
> git branch -a -v --no-abbrev # timeout=10
FATAL: String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1931)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.parseBranches(CliGitAPIImpl.java:1825)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getBranches(CliGitAPIImpl.java:1847)
at hudson.plugins.git.GitAPI.getBranches(GitAPI.java:195)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:1969)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:152)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:145)
at hudson.remoting.UserRequest.perform(UserRequest.java:120)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:332)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at ......remote call to jenkins-node-1(Native Method)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
at hudson.remoting.UserResponse.retrieve(UserRequest.java:220)
at hudson.remoting.Channel.call(Channel.java:781)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:145)
at sun.reflect.GeneratedMethodAccessor208.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:131)
at com.sun.proxy.$Proxy65.execute(Unknown Source)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1135)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1738)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)

-> turned out to be a DOS line ending in a commit message “...^M” - which leads to parsing an empty line here
====

versions:
jenkins-ci: Jenkins ver. 1.656
Git client plugin 1.19.6
Git plugin 2.4.4

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265)
Atlassian logo

mark.earl.waite@gmail.com (JIRA)

unread,
May 6, 2016, 6:30:01 PM5/6/16
to jenkinsc...@googlegroups.com

cbascom@gmail.com (JIRA)

unread,
May 28, 2016, 4:37:01 PM5/28/16
to jenkinsc...@googlegroups.com
Calvin Bascom commented on Bug JENKINS-34309
 
Re: git-client-plugin: StringIndexOutOfBoundsException when parsing branches

Just hit this as well, the DOS line ending in a commit message was the root cause for me as well.

n27@3ds.com (JIRA)

unread,
Jun 3, 2016, 10:30:02 AM6/3/16
to jenkinsc...@googlegroups.com

i have the same issue with git plugin 2.4.4 but in Jenkins 2.6.

[Pipeline] git
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url http://anakin.ux.dsone.3ds.com:10080/gitlab/3ds/wap.git # timeout=10
Fetching upstream changes from http://anakin.ux.dsone.3ds.com:10080/gitlab/3ds/wap.git
 > git --version # timeout=10
 > git -c core.askpass=true fetch --tags --progress http://anakin.ux.dsone.3ds.com:10080/gitlab/3ds/wap.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/release/419^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/release/419^{commit} # timeout=10
Checking out Revision cedc2f2495ca3c22d80e0c82de1727d55697e0bf (refs/remotes/origin/release/419)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f cedc2f2495ca3c22d80e0c82de1727d55697e0bf # timeout=10
 > git branch -a -v --no-abbrev # timeout=10
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1931)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.parseBranches(CliGitAPIImpl.java:1825)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getBranches(CliGitAPIImpl.java:1847)
	at hudson.plugins.git.GitAPI.getBranches(GitAPI.java:195)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:1969)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1135)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:83)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:73)
	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:49)
	at hudson.security.ACL.impersonate(ACL.java:213)
	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.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:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 5, 2016, 2:43:01 PM7/5/16
to jenkinsc...@googlegroups.com

Could one of your provide detailed instructions to create a repository which includes a DOS line ending in a commit message in such a way that it shows this bug? I'm interested in fixing the bug, but because I can't duplicate the bug, I can't really know if the bug is fixed.

This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

frank@zerofudge.de (JIRA)

unread,
Jul 5, 2016, 3:07:01 PM7/5/16
to jenkinsc...@googlegroups.com

in our case, this seems to be caused by git revert COMMIT - the default message generated by git contains a ^M at the end (ergo the empty line ergo the exception, fix seems obvious tho)

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 5, 2016, 3:32:02 PM7/5/16
to jenkinsc...@googlegroups.com

I've been surprised many times by what I thought were obvious fixes which exposed interesting and unexpected side effects when I duplicated the problem, wrote an automated test for the problem, then implemented a fix.

If you're not willing to provide detailed instructions, could you provide a sample repository that I can use as an example of the problem?

cbascom@gmail.com (JIRA)

unread,
Jul 5, 2016, 9:16:01 PM7/5/16
to jenkinsc...@googlegroups.com

To get a repo with a commit message having the DOS line ending, you can do the following:

git init
touch test.txt
git add test.txt
git commit -m "This is the first line^MFollowed by the second line"

To get that ^M character on MAC OS X, I used the key sequence Ctrl+V Ctrl+M. I think this should also work on linux.

That said, I don't have a repo in this state anymore since it was a short lived branch that caused this for me and I just deleted that branch. When I created a new branch with the above method, I am unable to reproduce this since the 'git branch -a -v --no-abbrev # timeout=10' command is not being executed under my current setup. Will update further if I am able to figure out what conditions cause that command to be executed.

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 6, 2016, 10:42:01 PM7/6/16
to jenkinsc...@googlegroups.com

I've created the branch JENKINS-34309 on my jenkins-bugs github repository. That branch includes an "ant" script (build.xml) which by default updates a file (build.number) and commits the update with a Ctrl+M embedded in the commit message.

I have a freestyle job polling that repository and that branch and don't see the failure.

I see an earlier reference to a pipeline job. Was your case using a pipeline job as well? If not, what job type were you using?

cbascom@gmail.com (JIRA)

unread,
Jul 7, 2016, 10:28:01 PM7/7/16
to jenkinsc...@googlegroups.com

My case was definitely a pipeline job but so far I am also unable to reproduce this even with a pipeline job.

frank@zerofudge.de (JIRA)

unread,
Jul 9, 2016, 10:10:03 AM7/9/16
to jenkinsc...@googlegroups.com

the error is caused by a trailing ^M in the commit message of the HEAD of an existing branch within the referenced repository, 100% reproducible

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 9, 2016, 10:45:01 AM7/9/16
to jenkinsc...@googlegroups.com

My ant skills are clearly lacking. I can't find a way from my Linux based development machine to place a trailing ^M in the commit message. I've tried with shell commands as well.

Any hints? Alternately, Frank Geusch could you provide a small repository which has the HEAD of one of its existing branches with a trailing ^M?

frank@zerofudge.de (JIRA)

unread,
Jul 9, 2016, 11:04:02 AM7/9/16
to jenkinsc...@googlegroups.com

i’m on it, matter-of-factly I also unable to provide an example currently - I’m guessing a certain older git version had this issue; some of my colleagues was inducing this a couple weeks ago, I will get into this on Monday;
also, this is rather a minor issue, as it easily mitigable by just tidying the culprit message

frank@zerofudge.de (JIRA)

unread,
Jul 9, 2016, 11:04:02 AM7/9/16
to jenkinsc...@googlegroups.com
Frank Geusch edited a comment on Bug JENKINS-34309
i’m on it, matter-of-factly I 'm also unable to provide an example currently - I’m guessing a certain older git version had this issue; some of my colleagues was inducing this a couple weeks ago, I will get into this on Monday;

also, this is rather a minor issue, as it easily mitigable by just tidying the culprit message

frank@zerofudge.de (JIRA)

unread,
Jul 9, 2016, 11:06:04 AM7/9/16
to jenkinsc...@googlegroups.com

frank@zerofudge.de (JIRA)

unread,
Jul 9, 2016, 11:07:01 AM7/9/16
to jenkinsc...@googlegroups.com
Frank Geusch edited a comment on Bug JENKINS-34309
i’m on it, matter-of-factly I'm also unable to provide an example currently - I’m guessing a certain older git version had this issue; some of my colleagues was inducing this a couple weeks ago, I will get into this on Monday;
also, this is rather a minor issue, as it is easily mitigable by just tidying up the culprit message

chris@chrisarndt.de (JIRA)

unread,
Jul 11, 2016, 4:27:01 AM7/11/16
to jenkinsc...@googlegroups.com

This bug is also triggered by this Gitlab bug:

https://gitlab.com/gitlab-org/gitlab-ce/issues/14453

The Gitlab bug has been fixed 4 months ago and is in the leatests releases, but since we hadn't updated yet, we were hit by it last week.

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 11, 2016, 3:57:02 PM7/11/16
to jenkinsc...@googlegroups.com

If you'd be willing to try a pre-release, pull request 213 has been built and can be downloaded from the pull request builder.].

It ran in my multi-platform test environment successfully, reporting no pareseBranches related StringIndexOutOfBoundsException messages in settings where I was previously seeing them.

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 11, 2016, 3:57:02 PM7/11/16
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-34309

It ran in my multi-platform test environment successfully, reporting no pareseBranches related StringIndexOutOfBoundsException messages in settings where I was previously seeing them.

chris@chrisarndt.de (JIRA)

unread,
Jul 13, 2016, 5:27:04 AM7/13/16
to jenkinsc...@googlegroups.com

Thanks for the info. I will talk to our admins about trying your branch. I hope it will be merged soon.

jammurp@us.ibm.com (JIRA)

unread,
Jul 13, 2016, 7:49:05 PM7/13/16
to jenkinsc...@googlegroups.com

Hi,

We hit the same issue during one of our builds, wanted to add that we were able to downgrade the git client plugin back to 1.8.1 to bypass the issue.
Not sure how to go back and search each commit that happened for a new line.... in our case the culprit commit is not the most recent, so we would need to go back and update ones that happened several commits ago... not sure how to do that yet....

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 13, 2016, 8:16:01 PM7/13/16
to jenkinsc...@googlegroups.com

Git client plugin 1.18.1 is quite old. Is there a reason you went backwards that far rather than trying the pre-release mentioned earlier?

jammurp@us.ibm.com (JIRA)

unread,
Jul 14, 2016, 1:02:03 PM7/14/16
to jenkinsc...@googlegroups.com

Hi Mark,

No special reason, it was the previously installed version, and I had known it was working then (plus the downgrade to previously installed version button was conveniently there).
Also we were against a deadline, and choose to downgrade instead of going through all the commits searching for messages that had newlines, and that second link you posted to download the build from is no longer pointing to an existing artifact...

jammurp@us.ibm.com (JIRA)

unread,
Jul 14, 2016, 2:11:02 PM7/14/16
to jenkinsc...@googlegroups.com

I downloaded and built the plugin from the master stream. After loading the pre-release plugin into Jenkins plugins, seems to be working fine. Thanks Mark.

jammurp@us.ibm.com (JIRA)

unread,
Jul 14, 2016, 2:11:02 PM7/14/16
to jenkinsc...@googlegroups.com
James Murphy edited a comment on Bug JENKINS-34309
I downloaded and built the plugin from the master stream branch . After loading the pre-release plugin into Jenkins plugins, seems to be working fine. Thanks Mark.

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 15, 2016, 11:02:03 PM7/15/16
to jenkinsc...@googlegroups.com
Mark Waite resolved as Fixed
 

Fixed in git client plugin 1.19.7 released 15 Jul 2016

Change By: Mark Waite
Status: Open Resolved
Resolution: Fixed

mark.earl.waite@gmail.com (JIRA)

unread,
Nov 27, 2019, 6:20:03 PM11/27/19
to jenkinsc...@googlegroups.com
Mark Waite closed an issue as Fixed
Change By: Mark Waite
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages