Jenkins building Git project fails release-start with StringIndexOutOfBoundsException

Declined
#56 · Created  · Last updated

Declined pull request

already fixed in https://bitbucket.org/atlassian/jgit-flow/pull-request/59/mjf-235-protect-against

Closed by: ·2015-06-30

Description

When we run a build on Jenkins, the git plugin does not do a standard clone and branch checkout.

Building remotely on xxxxx-Build (US-phantomjs npm nodejs linux) in workspace /home/jenkins/slave1/workspace/ci-test-release Cloning the remote Git repository Cloning repository http://xxxxx/ci-test.git > git init /home/jenkins/slave1/workspace/ci-test-release # timeout=10 Fetching upstream changes from http://xxxxx/ci-test.git > git --version # timeout=10 using .gitcredentials to set credentials > git config --local credential.helper store --file=/tmp/git1620537874302447631.credentials # timeout=10 > git -c core.askpass=true fetch --tags --progress http://xxxxx/ci-test.git +refs/heads/*:refs/remotes/origin/* > git config --local --remove-section credential # timeout=10 > git config remote.origin.url http://xxxxx/ci-test.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url http://xxxxx/ci-test.git # timeout=10 Cleaning workspace > git rev-parse --verify HEAD # timeout=10 No valid HEAD. Skipping the resetting > git clean -fdx # timeout=10 Fetching upstream changes from http://xxxxx/ci-test.git using .gitcredentials to set credentials > git config --local credential.helper store --file=/tmp/git5986866701052959369.credentials # timeout=10 > git -c core.askpass=true fetch --tags --progress http://xxxxx/ci-test.git +refs/heads/*:refs/remotes/origin/* > git config --local --remove-section credential # timeout=10 > git rev-parse refs/remotes/origin/develop^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10 Checking out Revision fb39f1fc02e942a0c616a0f7a2d63833ddd0a7554 (refs/remotes/origin/develop) > git config core.sparsecheckout # timeout=10 > git checkout -f fb39f1fc02e942a0c616a0f7a2d63833ddd0a7554 > git rev-list 5c2db479b4838155a0299d35b1aa1fdee1361e81 # timeout=10

It seems to do a git init and then fetch and then checks out a commit. This leaves:

[jenkins .git]$ cat HEAD 141010763cc9fb719caf38349366f3f7a95c1aba [jenkins .git]$ ls branches config description FETCH_HEAD HEAD hooks index info logs objects refs [jenkins .git]$ cat FETCH_HEAD 141010763cc9fb719caf38349366f3f7a95c1aba branch 'develop' of 1c13dc4082b073e78020ef5ae1184dbe11382e9c branch 'feature' of 1f4c1fff6cd2300aeac58d4b3eb280cae8723a24 branch 'master' of [jenkins .git]$ ls refs/ heads/ remotes/ tags/ [jenkins .git]$ ls refs/heads/ <nothing>

which results in, when we run release-start

java.lang.StringIndexOutOfBoundsException: String index out of range: -6 at java.lang.String.substring(String.java:1875) at com.atlassian.jgitflow.core.util.GitHelper.localBranchExists(GitHelper.java:216) at ut.com.atlassian.jgitflow.core.GitHelperTest.localBranchExists_WorksEvenWithNewRepoWithNoBranchesCheckedOut(GitHelperTest.java:285)

when the "refs/heads" is "subtracted" from the ref name.

I tried first to just test for the name "HEAD" and use that, but decided any name shorter than "refs/heads" should be treated as a single name.

I am not sure if Git even has anything like that - if you know, we can just look for HEAD.

In either case, something that results in a substring index of -1 is always an error in my book, so we throw a new JGitFlowGitAPIException. No test to prove that however.

0 attachments

0 comments

Loading commits...