Skip to content
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

Execution of git-commit-id-plugin in Docker build fails #518

Open
cheppsn opened this issue Aug 18, 2020 · 3 comments
Open

Execution of git-commit-id-plugin in Docker build fails #518

cheppsn opened this issue Aug 18, 2020 · 3 comments
Labels

Comments

@cheppsn
Copy link

cheppsn commented Aug 18, 2020

Describe the bug

Building with standard configuration from Bamboo in Docker image (mounting project directory with git repository) fails with

18-Aug-2020 22:06:17 | [INFO] --- git-commit-id-plugin:4.0.2:revision (default) @ **** ---
-- | --
18-Aug-2020 22:06:17 | [INFO] dotGitDirectory /data/.git
18-Aug-2020 22:06:24 | [WARNING] locking FileBasedConfig[/root/.config/jgit/config] failed after 5 retries
18-Aug-2020 22:06:24 | [INFO] ------------------------------------------------------------------------
18-Aug-2020 22:06:24 | [INFO] BUILD FAILURE
18-Aug-2020 22:06:24 | [INFO] ------------------------------------------------------------------------
18-Aug-2020 22:06:24 | [INFO] Total time:  8.449 s
18-Aug-2020 22:06:24 | [INFO] Finished at: 2020-08-18T20:06:24Z
18-Aug-2020 22:06:24 | [INFO] ------------------------------------------------------------------------
18-Aug-2020 22:06:24 | [ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.0.2:revision (default) on project ****: Could not complete Mojo execution...: Error: Missing unknown bc06d4f079f817a2827803c9f12b6833ec2bfcfb -> [Help 1]
18-Aug-2020 22:06:24 | [ERROR]
18-Aug-2020 22:06:24 | [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
18-Aug-2020 22:06:24 | [ERROR] Re-run Maven using the -X switch to enable full debug logging.
18-Aug-2020 22:06:24 | [ERROR]
18-Aug-2020 22:06:24 | [ERROR] For more information about the errors and possible solutions, please read the following articles:
18-Aug-2020 22:06:24 | [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
18-Aug-2020 22:06:25 | Exit code: 1, output: STDOUT:  [INFO] --------------------------------[ jar ]---------------------------------STDOUT:  [INFO] STDOUT:  [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ **** ---STDOUT:  [INFO] STDOUT:  [INFO] --- git-commit-id-plugin:4.0.2:revision (default) @ **** ---STDOUT:  [INFO] dotGitDirectory /data/.git STDOUT:  [WARNING] locking FileBasedConfig[/root/.config/jgit/config] failed after 5 retries STDOUT:  [INFO] ------------------------------------------------------------------------STDOUT:  [INFO] BUILD FAILURESTDOUT:  [INFO] ------------------------------------------------------------------------STDOUT:  [INFO] Total time:  8.449 sSTDOUT:  [INFO] Finished at: 2020-08-18T20:06:24ZSTDOUT:  [INFO] ------------------------------------------------------------------------STDOUT:  [ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.0.2:revision (default) on project carbonapp: Could not complete Mojo execution...: Error: Missing unknown bc06d4f079f817a2827803c9f12b6833ec2bfcfb 
...

Steps to Reproduce

<plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>4.0.2</version>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                        <phase>initialize</phase>
                    </execution>
                </executions>
                <configuration>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
                    <includeOnlyProperties>
                        <includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
                        <includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
                        <includeOnlyProperty>^git.dirty$</includeOnlyProperty>
                    </includeOnlyProperties>
                    <commitIdGenerationMode>full</commitIdGenerationMode>
                </configuration>
            </plugin>

Execute mvn clean package in docker container from Bamboo build, project directory mounted as /data.

Expected behavior

Error should not occur.

Additional context

I don't know if the git-commit-id-plugin uses JGit behind the scenes, but this seems to be the same problem as described here: https://community.sonarsource.com/t/error-locking-filebasedconfig-root-config-jgit-config-failed-after-5-retries/21899.

I suspect that this is happening, because the JGit config is created inside the /root directory of the docker container, which is a different drive than /data drive where the git repo is mounted.

I did open an eclipse bug for JGit: https://bugs.eclipse.org/bugs/show_bug.cgi?id=566170

@cheppsn
Copy link
Author

cheppsn commented Aug 18, 2020

https://community.sonarsource.com/t/error-locking-filebasedconfig-root-config-jgit-config-failed-after-5-retries/21899 apparently also describes a workaround that could be used, if a newer JGit version doesn't fix the problem.

@TheSnoozer
Copy link
Collaborator

Hello,
thank you for reporting! This indeed sounds a quite tricky bug within the JGit library which is being used by the plugin by default.

Some questions:

  • what container are you using? is it a public one, so I can reproduce the issue myself?
  • How does the plugin version git-commit-id-plugin:4.0.1 behave? Based on Update dependencies #514 the 4.0.1 version should be still using some older JGit dependency (5.2.2.201904231744-r based on the commit history)

Since this seems to be a JGit issue you should also be able to bypass the problem by setting <useNativeGit>true</useNativeGit> inside the plugin config (regardless if you are using the 4.0.1 or 4.0.2 version of the plugin). As a disclaimer this will tell the plugin to use the native git binary instead of the JGit implementation. As a result your container needs to have git on the executable path.

Besides that I don't think i can do much from the plugin perspective (just waiting until JGit fixed the issue or using the native git binary as suggested)

@TheSnoozer TheSnoozer added the bug label Aug 18, 2020
@cheppsn
Copy link
Author

cheppsn commented Aug 19, 2020

I am using maven:3.6.3-openjdk-8 as a container.

docker run --volume /home/bamboo/xml-data/build-dir/myproject:/data --volume /home/bamboo/.m2:/root/.m2 --workdir /data --rm maven:3.6.3-openjdk-8 mvn clean package

Unfortunately if I execute that on my (Windows) machine I cannot reproduce the problem, while the Bamboo build fails every time (Linux).

However, thanks a lot for your suggestions! I tried them both:

  • using native git fixes the problem (luckily the container contains git)
  • using the older plugin-version does not work

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

No branches or pull requests

2 participants