git-commit-id-maven-plugin icon indicating copy to clipboard operation
git-commit-id-maven-plugin copied to clipboard

Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.0.0:revision (default) on project <project-name>: Could not complete Mojo execution... Missing tree <commit hash>

Open froblesmartin opened this issue 5 years ago • 6 comments

Describe the bug

We are testing the Jenkins MultiBranch Pipeline setting to use a reference repository to avoid using too much bandwidth.

Only when we activate it we get this issue with the plugin:

Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.0.0:revision (default) on project <project-name>: Could not complete Mojo execution... Missing tree <commit hash>

If running it with the useNativeGit as true we get this error: [ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.0.0:revision (default) on project [project-name]: Could not complete Mojo execution... pl.project13.core.NativeGitProvider$NativeCommandException: Git command exited with invalid status [128]: directory: '/var/lib/jenkins/workspace/[branch]/[folder]', command: 'git describe --always --dirty=-dirty --match=* --abbrev=7', stdout: '', stderr: 'error: object directory /var/lib/jenkins/gitcache/[repository-name].git/objects does not exist; check .git/objects/info/alternates.fatal: unable to read tree [commit hash]' -> [Help 1]

The /var/lib/jenkins/gitcache/[repository-name].git is where we have the reference repository. It looks like the plugin is trying to get the info from that one which is a mirror and does not have the .git folder.

Steps to Reproduce

<plugin>
    <groupId>pl.project13.maven</groupId>
    <artifactId>git-commit-id-plugin</artifactId>
    <version>4.0.0</version>
    <configuration>
        <verbose>false</verbose>
        <useNativeGit>true</useNativeGit>
    </configuration>
</plugin>

Expected behavior

Just to work fine as usual with this reference repository.

Additional context

For reproducibility please provide the following:

  • OpenJDK version "1.8.0_181"
  • Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T18:33:14Z)
  • Debian GNU/Linux 9.5 (stretch)
  • It is being used with /bin/bash
  • How maven is being executed: mvn clean install

We were using version 3.0.0 but it get's the same issue with 4.0.0

Any idea on what's going on exactly here?

froblesmartin avatar Dec 31 '19 09:12 froblesmartin

Hello, thank you for reporting your issue here (and sorry for the late response).

In theory this should work - especially with the native git-binary (<useNativeGit>true</useNativeGit>). At least when testing locally this seems to work:

$ git clone --mirror [email protected]:TheSnoozer/git-commit-id-debugging.git
$ cd git-commit-id-debugging.git
$ git describe --always --dirty=-dirty --match=* --abbrev=7
git-commit-id-plugin-debugging-0.0.2-8-gf5af67c-dirty

Hence I'm not exactly sure what is going on here, but it seems that the plugin attempts to run git describe --always --dirty=-dirty --match=* --abbrev=7 within the directory /var/lib/jenkins/workspace/<branch>/<folder> however the reference repository seems to be located in /var/lib/jenkins/gitcache/.git - perhaps this is already the issue?? Can you try to run git describe --always --dirty=-dirty --match=* --abbrev=7 in the /var/lib/jenkins/workspace/<branch>/<folder> directory manually? What exactly does this directory contain? Is it a valid git directory?

In your case i would attempt to specify the dotGitDirectory to <dotGitDirectory> /var/lib/jenkins/gitcache/<repository-name>.git</dotGitDirectory>. In practice this should fall-back to ${project.basedir}/.git which currently does not work for you.

TheSnoozer avatar Jan 03 '20 21:01 TheSnoozer

Hi @TheSnoozer! Thanks for you reply!

First of all, I wrote some folders with '<' and '>' but MarkDown does not display those...I have changed it using '[' and ']', now you can see things right in the first post.

Also, Git version is 2.11.0 on the server (this might be the issue with the native Git...).

I have executed the command git describe --always --dirty=-dirty --match=* --abbrev=7 in the repository mirror folder (/var/lib/jenkins/gitcache/[repository-name].git) and I get this result: fatal: This operation must be run in a work tree. That's basically the same thing you did locally. The issue is on the --dirty parameter, without it the command runs just fine.

froblesmartin avatar Jan 07 '20 12:01 froblesmartin

I meet the same mistake.

shaowenchen avatar Apr 23 '20 11:04 shaowenchen

[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.9.10:revision (get-the-git-infos) on project ZConnector: Could not complete Mojo execution...: Illegal/unsupported escape sequence near index 3
[ERROR] D:\gitprojects\zconnector\ZConnectorEAR/src/main/application/git.properties

I think problem are the Windows backslashes.

<generateGitPropertiesFilename>${project.basedir}/src/main/application/git.properties</generateGitPropertiesFilename>

When I removed the variable, problem went away.

weberjn avatar Feb 01 '22 13:02 weberjn

We experienced a similar issue in Hazelcast after bumping the git-commit-id plugin version from 2.1.10 to 4.9.10 (see hazelcast/hazelcast#20075). We don't use native git. This is our plugin configuration;

            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>${maven.git.commit.id.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <useNativeGit>false</useNativeGit>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <failOnNoGitDirectory>false</failOnNoGitDirectory>
                    <abbrevLength>7</abbrevLength>
                    <gitDescribe>
                        <skip>true</skip>
                    </gitDescribe>
                </configuration>
            </plugin>

After the version update the Pull request CI sometimes fail with:

03:09:58 [ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.9.10:revision (default) on project hazelcast: Could not complete Mojo execution... Missing tree 2a16e70f898cd00b6ae18a9967010c239ffe6d55 -> [Help 1]
03:09:58 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.9.10:revision (default) on project hazelcast: Could not complete Mojo execution...
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
03:09:58     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
03:09:58     at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
03:09:58     at java.lang.Thread.run (Thread.java:748)
03:09:58 Caused by: org.apache.maven.plugin.MojoExecutionException: Could not complete Mojo execution...
03:09:58     at pl.project13.maven.git.GitCommitIdMojo.execute (GitCommitIdMojo.java:542)
03:09:58     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
03:09:58     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
03:09:58     at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
03:09:58     at java.lang.Thread.run (Thread.java:748)
03:09:58 Caused by: pl.project13.core.GitCommitIdExecutionException: Could not complete Mojo execution...
03:09:58     at pl.project13.maven.git.GitCommitIdMojo.handlePluginFailure (GitCommitIdMojo.java:634)
03:09:58     at pl.project13.maven.git.GitCommitIdMojo.execute (GitCommitIdMojo.java:539)
03:09:58     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
03:09:58     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
03:09:58     at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
03:09:58     at java.lang.Thread.run (Thread.java:748)
03:09:58 Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Missing tree 2a16e70f898cd00b6ae18a9967010c239ffe6d55
03:09:58     at org.eclipse.jgit.api.StatusCommand.call (StatusCommand.java:128)
03:09:58     at pl.project13.core.jgit.JGitCommon.isRepositoryInDirtyState (JGitCommon.java:338)
03:09:58     at pl.project13.core.JGitProvider.isDirty (JGitProvider.java:184)
03:09:58     at pl.project13.core.GitDataProvider.lambda$loadGitData$1 (GitDataProvider.java:151)
03:09:58     at pl.project13.core.GitDataProvider.maybePut (GitDataProvider.java:259)
03:09:58     at pl.project13.core.GitDataProvider.loadGitData (GitDataProvider.java:151)
03:09:58     at pl.project13.maven.git.GitCommitIdMojo.loadGitDataWithJGit (GitCommitIdMojo.java:711)
03:09:58     at pl.project13.maven.git.GitCommitIdMojo.loadGitData (GitCommitIdMojo.java:670)
03:09:58     at pl.project13.maven.git.GitCommitIdMojo.execute (GitCommitIdMojo.java:516)
03:09:58     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
03:09:58     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
03:09:58     at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
03:09:58     at java.lang.Thread.run (Thread.java:748)
03:09:58 Caused by: org.eclipse.jgit.errors.MissingObjectException: Missing tree 2a16e70f898cd00b6ae18a9967010c239ffe6d55
03:09:58     at org.eclipse.jgit.internal.storage.file.WindowCursor.open (WindowCursor.java:137)
03:09:58     at org.eclipse.jgit.treewalk.CanonicalTreeParser.reset (CanonicalTreeParser.java:191)
03:09:58     at org.eclipse.jgit.treewalk.CanonicalTreeParser.createSubtreeIterator0 (CanonicalTreeParser.java:226)
03:09:58     at org.eclipse.jgit.treewalk.CanonicalTreeParser.createSubtreeIterator (CanonicalTreeParser.java:204)
03:09:58     at org.eclipse.jgit.treewalk.CanonicalTreeParser.createSubtreeIterator (CanonicalTreeParser.java:1)
03:09:58     at org.eclipse.jgit.treewalk.TreeWalk.enterSubtree (TreeWalk.java:1270)
03:09:58     at org.eclipse.jgit.treewalk.TreeWalk.next (TreeWalk.java:826)
03:09:58     at org.eclipse.jgit.lib.IndexDiff.diff (IndexDiff.java:477)
03:09:58     at org.eclipse.jgit.lib.IndexDiff.diff (IndexDiff.java:379)
03:09:58     at org.eclipse.jgit.lib.IndexDiff.diff (IndexDiff.java:354)
03:09:58     at org.eclipse.jgit.api.StatusCommand.call (StatusCommand.java:122)
03:09:58     at pl.project13.core.jgit.JGitCommon.isRepositoryInDirtyState (JGitCommon.java:338)
03:09:58     at pl.project13.core.JGitProvider.isDirty (JGitProvider.java:184)
03:09:58     at pl.project13.core.GitDataProvider.lambda$loadGitData$1 (GitDataProvider.java:151)
03:09:58     at pl.project13.core.GitDataProvider.maybePut (GitDataProvider.java:259)
03:09:58     at pl.project13.core.GitDataProvider.loadGitData (GitDataProvider.java:151)
03:09:58     at pl.project13.maven.git.GitCommitIdMojo.loadGitDataWithJGit (GitCommitIdMojo.java:711)
03:09:58     at pl.project13.maven.git.GitCommitIdMojo.loadGitData (GitCommitIdMojo.java:670)
03:09:58     at pl.project13.maven.git.GitCommitIdMojo.execute (GitCommitIdMojo.java:516)
03:09:58     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
03:09:58     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
03:09:58     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
03:09:58     at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
03:09:58     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
03:09:58     at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
03:09:58     at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
03:09:58     at java.lang.Thread.run (Thread.java:748)
03:09:58 [ERROR] 
03:09:58 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
03:09:58 [ERROR] 
03:09:58 [ERROR] For more information about the errors and possible solutions, please read the following articles:
03:09:58 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
03:09:58 [ERROR] 
03:09:58 [ERROR] After correcting the problems, you can resume the build with the command
03:09:58 [ERROR]   mvn <args> -rf :hazelcast

We reverted the update for now.

kwart avatar Feb 03 '22 08:02 kwart

Is the Missing tree issue resolved when using the native git version (so <useNativeGit>true</useNativeGit>)?

TheSnoozer avatar Feb 06 '22 17:02 TheSnoozer

I meet the same ERROR! Have you solved this ERROR?

wyzhhhh avatar Dec 04 '22 04:12 wyzhhhh

I meet the same ERROR! Have you solved this ERROR?

Short summary: First start to verify if your local cloned repository is fine. Maven should display more details about what exactly went wrong. E.g. in the initial issue the user identified that running the command: 'git describe --always --dirty=-dirty --match=* --abbrev=7'. As first action I would recommend to run the same command manually (e.g. open a shell or terminal) and also include native git commands like git rev-parse HEAD.

If those commands work just fine try adding the plugin configuration <useNativeGit>true</useNativeGit> and see if this fixes the problem.

If the native commands like git rev-parse HEAD do not work in the terminal or shell, reclone your repository until they do.

If maven doesn't tell you try adding the option -e -X to the command-line.

TheSnoozer avatar Dec 04 '22 18:12 TheSnoozer

The result is the same with <useNativeGit>true</useNativeGit>

ario-afrashteh avatar Jun 16 '23 11:06 ario-afrashteh

Closing as this is stale.

froblesmartin avatar Oct 11 '23 10:10 froblesmartin