Skip to content

FAILED: runGitDescribeWithMatchOption, has trouble on Travis #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ktoso opened this issue Dec 8, 2014 · 11 comments · Fixed by #147
Closed

FAILED: runGitDescribeWithMatchOption, has trouble on Travis #146

ktoso opened this issue Dec 8, 2014 · 11 comments · Fixed by #147
Assignees
Labels
Milestone

Comments

@ktoso
Copy link
Collaborator

ktoso commented Dec 8, 2014

This test runGitDescribeWithMatchOption has trouble on travis, see: https://travis-ci.org/ktoso/maven-git-commit-id-plugin/builds/43299247

java.lang.RuntimeException: Failed to execute git command (`git symbolic-ref HEAD` @ /home/travis/build/ktoso/maven-git-commit-id-plugin/target/sandbox/my-pom-project/my-jar-module)!
    at pl.project13.maven.git.NativeGitProvider.runGitCommand(NativeGitProvider.java:271)
    at pl.project13.maven.git.NativeGitProvider.tryToRunGitCommand(NativeGitProvider.java:236)
    at pl.project13.maven.git.NativeGitProvider.getBranch(NativeGitProvider.java:76)
    at pl.project13.maven.git.NativeGitProvider.getBranchName(NativeGitProvider.java:72)
    at pl.project13.maven.git.GitDataProvider.determineBranchName(GitDataProvider.java:142)
    at pl.project13.maven.git.GitDataProvider.loadGitData(GitDataProvider.java:86)
    at pl.project13.maven.git.GitCommitIdMojo.loadGitDataWithNativeGit(GitCommitIdMojo.java:477)
    at pl.project13.maven.git.GitCommitIdMojo.loadGitData(GitCommitIdMojo.java:460)
    at pl.project13.maven.git.GitCommitIdMojo.execute(GitCommitIdMojo.java:320)
    at pl.project13.maven.git.GitCommitIdMojoIntegrationTest.runGitDescribeWithMatchOption(GitCommitIdMojoIntegrationTest.java:649)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at junitparams.internal.InvokeParameterisedMethod.evaluate(InvokeParameterisedMethod.java:184)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at junitparams.internal.ParameterisedTestMethodRunner.runMethodInvoker(ParameterisedTestMethodRunner.java:48)
    at junitparams.internal.ParameterisedTestMethodRunner.runTestMethod(ParameterisedTestMethodRunner.java:42)
    at junitparams.internal.ParameterisedTestClassRunner.runParameterisedTest(ParameterisedTestClassRunner.java:143)
    at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:405)
    at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:383)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.io.IOException: Git command exited with invalid status [128]: stdout: ``, stderr: `fatal: ref HEAD is not a symbolic ref`
    at pl.project13.maven.git.NativeGitProvider$JavaProcessRunner.run(NativeGitProvider.java:315)
    at pl.project13.maven.git.NativeGitProvider.runGitCommand(NativeGitProvider.java:267)
    ... 41 more
TEST: Will prepare sandbox repository based on: [src/test/resources/_git_one_commit]
TEST: Will prepare sandbox repository based on: [src/test/resources/_git_one_commit]
TEST: Will prepare sandbox repository based on: [src/test/resources/_git_one_commit]
TEST: Will prepare sandbox repository based on: [src/test/resources/_git_one_commit]
TEST: Will prepare sandbox repository based on: [src/test/resources/_git_one_commit]
TEST: Will prepare sandbox repository based on: [src/test/resources/_git_one_commit]
Tests run: 50, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 3.04 sec <<< FAILURE!
[1] true (runGitDescribeWithMatchOption)(pl.project13.maven.git.GitCommitIdMojoIntegrationTest)  Time elapsed: 0.037 sec  <<< FAILURE!
@ktoso ktoso added the bug label Dec 8, 2014
@ktoso ktoso self-assigned this Dec 8, 2014
@ktoso
Copy link
Collaborator Author

ktoso commented Dec 8, 2014

I expect this to be some kind of travis specific thing...

@TheSnoozer
Copy link
Collaborator

I just checked this with on Hudson....

$ git status
# Not currently on any branch.
nothing to commit (working directory clean)

$ git symbolic-ref HEAD
fatal: ref HEAD is not a symbolic ref

seems to be a CI related problem....

@ktoso
Copy link
Collaborator Author

ktoso commented Dec 8, 2014

is it a shallow clone or a deep one?

-- 
Konrad 'ktoso’ Malawski
hAkker @ typesafe
akka.io / java.pl / geecon.org / krakowscala.pl / gdgkrakow.pl

On 8 December 2014 at 22:40:33, TheSnoozer (notifications@github.com) wrote:

I just checked this with on Hudson....

$ git status

Not currently on any branch.

nothing to commit (working directory clean)

$ git symbolic-ref HEAD
fatal: ref HEAD is not a symbolic ref

seems to be a CI related problem....


Reply to this email directly or view it on GitHub.

@TheSnoozer
Copy link
Collaborator

shallow with depth of 100

@ktoso
Copy link
Collaborator Author

ktoso commented Dec 8, 2014

mind investigating a bit more? does it work with not shallow?
what’s the most recent tag etc?

-- 
Konrad 'ktoso’ Malawski
hAkker @ typesafe
akka.io / java.pl / geecon.org / krakowscala.pl / gdgkrakow.pl

On 8 December 2014 at 22:43:07, TheSnoozer (notifications@github.com) wrote:

shallow with depth of 100


Reply to this email directly or view it on GitHub.

@ktoso
Copy link
Collaborator Author

ktoso commented Dec 8, 2014

How does the native impl behave

-- 
Konrad 'ktoso’ Malawski
hAkker @ typesafe
akka.io / java.pl / geecon.org / krakowscala.pl / gdgkrakow.pl

On 8 December 2014 at 22:43:07, TheSnoozer (notifications@github.com) wrote:

shallow with depth of 100


Reply to this email directly or view it on GitHub.

@TheSnoozer
Copy link
Collaborator

I try to investigate, stay tuned....
Well I'm issing the commands on terminal...
not using the git-commit-id-plugin at this stage....just tought would be a CI-Problem...

I builded a wrapper around git, to get the actual commands...
Thats how Hudson checks out a repro....:

/usr/bin/git.org.1.7.0.4 fetch -t ssh://user@ip/git.git +refs/heads/*:refs/remotes/origin/* --depth=100
/usr/bin/git.org.1.7.0.4 checkout -f 30dad64b4f6cbcb9798fc2c901df908efc810f10

@TheSnoozer
Copy link
Collaborator

I finally got it reproduced on my local machine....
Hudson does the following when checkig out "master":

git fetch -t git://github.com/ktoso/maven-git-commit-id-plugin.git +refs/heads/*:refs/remotes/origin/* --depth=100
git tag -l master
git rev-parse origin/master
git checkout -f 389edc660e8655f766e75528248ee1bd23fe964d
git tag -a -f -m Hudson Build #12 hudson-git_commit_check-12
git whatchanged --no-abbrev -M --pretty=raw 389edc660e8655f766e75528248ee1bd23fe964d..389edc660e8655f766e75528248ee1bd23fe964d

To reproduce locallay run a git init before and you can skip the tag...

After doing this all you are in 'detached HEAD' state and there will be no symbolic HEAD, resulting in

$ git symbolic-ref HEAD
fatal: ref HEAD is not a symbolic ref

Additionally git show-ref will return this

$ git show-ref
54283e5b740f3d82f8baa8c5de6b3da702e9dc0f refs/remotes/origin/gh-pages
389edc660e8655f766e75528248ee1bd23fe964d refs/remotes/origin/master
ace26d96ab84bf1b325724edd33d32e9d8aebe45 refs/remotes/origin/native
7319382b810f4255440e380b2b1d313c0a2e55f2 refs/remotes/origin/native-git
853886dfd27920d714d7ab07d391680b4407e846 refs/remotes/origin/tomasol-master
16c85b8d649a34c40056355af1e1f82b0d2c9d76 refs/tags/v1.0
[....]

@ktoso
Copy link
Collaborator Author

ktoso commented Dec 8, 2014

Thanks a lot!
Actually, we have a failing test for this… 
Will have to think what we can do about this - not using resolve HEAD - sure. but what to replace it with hm hm

-- 
Konrad 'ktoso’ Malawski
hAkker @ typesafe
akka.io / java.pl / geecon.org / krakowscala.pl / gdgkrakow.pl

On 9 December 2014 at 00:16:22, TheSnoozer (notifications@github.com) wrote:

I finally got it reproduced on my local machine....
Hudson does the following when checkig out "master":

git fetch -t git://github.com/ktoso/maven-git-commit-id-plugin.git +refs/heads/:refs/remotes/origin/ --depth=100
git tag -l master
git rev-parse origin/master
git checkout -f 389edc6
git tag -a -f -m Hudson Build #12 hudson-git_commit_check-12
git whatchanged --no-abbrev -M --pretty=raw 389edc6..389edc6

To reproduce locallay run a git init before and you can skip the tag...

After doing this all you are in 'detached HEAD' state and there will be no symbolic HEAD, resulting in

$ git symbolic-ref HEAD
fatal: ref HEAD is not a symbolic ref

Additionally git show-ref will return this

$ git show-ref
54283e5 refs/remotes/origin/gh-pages
389edc6 refs/remotes/origin/master
ace26d9 refs/remotes/origin/native
7319382 refs/remotes/origin/native-git
853886d refs/remotes/origin/tomasol-master
16c85b8d649a34c40056355af1e1f82b0d2c9d76 refs/tags/v1.0
[....]


Reply to this email directly or view it on GitHub.

@TheSnoozer
Copy link
Collaborator

No worries, always here to help ;)
Just as a suggestion:
Since this normally failes in a CI environment we could use the "GIT_BRANCH" Environment-Variable which will be exposed by CI-Tools during Build.

So a more less fix would be:

  1. try to obtain branch with git symbolic-ref HEAD
  2. only if 1) failes try to obtain branch by environment variable

If we still can not obtain the Branch Information I suggest the plugin should output a WARNING and leave the branch blank...

Also for future reference:
http://stackoverflow.com/a/19585361

@TheSnoozer
Copy link
Collaborator

Btw. In case of 'DETACHED HEAD' the JGIT Implementation outputs the SHA of the commit

git.branch=389edc660e8655f766e75528248ee1bd23fe964d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants