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

Failed to perform fetch

Open takeseem opened this issue 5 years ago • 6 comments

mvn clean package

[ERROR] Failed to perform fetch
org.eclipse.jgit.api.errors.TransportException: ssh://[email protected]:5353/plat/my-framework.git: remote hung up unexpectedly
    at org.eclipse.jgit.api.FetchCommand.call (FetchCommand.java:222)
    at pl.project13.core.JGitProvider.fetch (JGitProvider.java:350)
...
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.jgit.transport.SshSessionFactory.getSession(org.eclipse.jgit.transport.URIish, org.eclipse.jgit.transport.CredentialsProvider, org.eclipse.jgit.util.FS, int)" because "this.sch" is null
    at org.eclipse.jgit.transport.SshTransport.getSession (SshTransport.java:107)
<plugin>
  <groupId>pl.project13.maven</groupId>
  <artifactId>git-commit-id-plugin</artifactId>
  <version>4.0.3</version>
  <executions>
    <execution>
      <goals>
        <goal>revision</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <verbose>true</verbose>
    <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
    <generateGitPropertiesFile>true</generateGitPropertiesFile>
    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
  </configuration>
</plugin>

I found tow method to fix it.

  1. use nativegit: -Dmaven.gitcommitid.nativegit=true
  2. add jgit jsch dependency for git-commit-id-plugin
<plugin>
  <groupId>pl.project13.maven</groupId>
  <artifactId>git-commit-id-plugin</artifactId>
...
  <dependencies>
    <dependency>
      <groupId>org.eclipse.jgit</groupId>
      <artifactId>org.eclipse.jgit.ssh.jsch</artifactId>
      <version>5.9.0.202009080501-r</version>
    </dependency>
  </dependencies>
</plugin>

because of eclipse:jgit remove DefaultSshSessionFactory Use ServiceLoader to define the default SSH session factory

takeseem avatar Jan 20 '21 07:01 takeseem

Hi, thanks for creating a ticket for this. Could you perhaps try the workaround outlined in https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/458#issuecomment-564670250 and see if this helps?

TheSnoozer avatar Jan 20 '21 08:01 TheSnoozer

Hi, thanks for creating a ticket for this. Could you perhaps try the workaround outlined in #458 (comment) and see if this helps?

@TheSnoozer Thanks for your help.

The end of this's ticket have tow fix methods, include useNativeGit.

I think the best fix git-commit-id-plugin need to add a dependency org.eclipse.jgit:org.eclipse.jgit.ssh.jsch. because of the default ssh factory jsch move from jgit to org.eclipse.jgit:org.eclipse.jgit.ssh.jsch.

eclipse:jgit Use ServiceLoader to define the default SSH session factory

takeseem avatar Jan 21 '21 03:01 takeseem

Hi, sorry for the delay here. I now finally had the time to add the dependency.

Could you perhaps try if this fixes the issue? The version git-commit-id-plugin-4.0.5-20210317.082438-4 is available under https://oss.sonatype.org/content/repositories/snapshots/pl/project13/maven/git-commit-id-plugin/4.0.5-SNAPSHOT/ and should be available when adding the this snippet to your pom.

Thanks!

TheSnoozer avatar Mar 17 '21 08:03 TheSnoozer

Assuming this is fixed with the additional dependency from https://github.com/git-commit-id/git-commit-id-maven-plugin/pull/547

TheSnoozer avatar Jun 09 '21 15:06 TheSnoozer

For what is worth, I confirm the additional dependency fixes the issue!

zxxz avatar Jun 09 '21 19:06 zxxz

Thanks! That certainly adds confidence that this issue doesn't come back :-)

TheSnoozer avatar Jun 09 '21 19:06 TheSnoozer