Git-commit-id-maven-plugin: Have the plugin operate in "offline mode" by default to prevent issues since 3.x where the revision goal throws Exception: Caused by: com.jcraft.jsch.JSchException: Auth fail

Created on 11 Dec 2019  Â·  2Comments  Â·  Source: git-commit-id/git-commit-id-maven-plugin

Description

When i use the Springboot 2.2.x, its default version of git-commit-id is 3.0.1, but this version will cause build error log and there is no problem with git-commit-id:2.2.6. Here is the exception segment:

org.eclipse.jgit.api.errors.TransportException: [email protected]: Auth fail
    at org.eclipse.jgit.api.FetchCommand.call (FetchCommand.java:254)
    at pl.project13.core.JGitProvider.fetch (JGitProvider.java:351)
    at pl.project13.core.JGitProvider.getAheadBehind (JGitProvider.java:338)
    at pl.project13.core.GitDataProvider.lambda$memoize$6 (GitDataProvider.java:274)
    at pl.project13.core.GitDataProvider.lambda$loadGitData$2 (GitDataProvider.java:177)
    at pl.project13.core.GitDataProvider.maybePut (GitDataProvider.java:257)
    at pl.project13.core.GitDataProvider.loadGitData (GitDataProvider.java:177)
    at pl.project13.maven.git.GitCommitIdMojo.loadGitDataWithJGit (GitCommitIdMojo.java:639)
    at pl.project13.maven.git.GitCommitIdMojo.loadGitData (GitCommitIdMojo.java:598)
    at pl.project13.maven.git.GitCommitIdMojo.execute (GitCommitIdMojo.java:489)

I read the source code and find that : since 3.x , add two properties (GitDataProvider#loadGitData line 174)

SupplierEx<AheadBehind> aheadBehindSupplier = memoize(() -> getAheadBehind());
maybePut(properties, GitCommitPropertyConstant.LOCAL_BRANCH_AHEAD, () -> aheadBehindSupplier.get().ahead());
maybePut(properties, GitCommitPropertyConstant.LOCAL_BRANCH_BEHIND, () -> aheadBehindSupplier.get().behind());

This looks like lead to the problem : it will connect the remote git repository and get some infos, that is the Auth fail and i don't know how to fix it(my native git works well, the .ssh directory has no problem)

Expected behavior

when mvn compile , i expect no error logs, even if it was ignored and the build is finally "SUCCESS".

Additional context

plugin version : 3.0.1
maven : 3.6.1
os: mac
command: mvn compile

BREAKING

Most helpful comment

Hi,
thanks for reporting your problem here.....I feel like this plugin should go ahead and not include those properties, since it seems to cause a lot of problems.
In general this seems related to https://github.com/git-commit-id/maven-git-commit-id-plugin/issues/450 and https://github.com/git-commit-id/maven-git-commit-id-plugin/issues/446 and is now the third issue reported about this.

So far you have the following ways to avoid this issue:

  • set <offline>true</offline>
  • use native <useNativeGit>true</useNativeGit>

If you don't have control over the direct config you can also use -Dmaven.gitcommitid.nativegit=true as command-line argument.

All 2 comments

Hi,
thanks for reporting your problem here.....I feel like this plugin should go ahead and not include those properties, since it seems to cause a lot of problems.
In general this seems related to https://github.com/git-commit-id/maven-git-commit-id-plugin/issues/450 and https://github.com/git-commit-id/maven-git-commit-id-plugin/issues/446 and is now the third issue reported about this.

So far you have the following ways to avoid this issue:

  • set <offline>true</offline>
  • use native <useNativeGit>true</useNativeGit>

If you don't have control over the direct config you can also use -Dmaven.gitcommitid.nativegit=true as command-line argument.

I also encountered this issue and boiled it down to:

this key format doesn't work:

$ cat .ssh/id_rsa.1
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
...
vjiVVknjWq7xuXAAAAE2Rvd25zYkBDMDJERDNMOE1ENlIBAgMEBQYH
-----END OPENSSH PRIVATE KEY-----

whereas this key format does work:

$ cat .ssh/id_rsa.2
-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEAwIWbE9M6dCF90tzUzmugJhA2X3S4FxD1zlMpITtYfwrFtaXC
...
0t/tp7y3Cl6gR+/f8ave+H639ajP0LGu23CYkwaGlwYVxlEPCMF8oTHXOxY=
-----END RSA PRIVATE KEY-----
Was this page helpful?
0 / 5 - 0 ratings