jreleaser / jreleaser

:rocket: Release projects quickly and easily with JReleaser
https://jreleaser.org
Apache License 2.0
941 stars 109 forks source link

[release] NPE during tagging #1435

Open gunnarmorling opened 1 year ago

gunnarmorling commented 1 year ago

Getting this one:

Caused by: org.eclipse.jgit.api.errors.TransportException: git@github.com:decodableco/decodable-job-sdk.git: remote hung up unexpectedly
        at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:147)
        at org.jreleaser.sdk.git.release.ReleaseUtils.tagRelease(ReleaseUtils.java:90)
        ... 128 more
Caused by: org.eclipse.jgit.errors.TransportException: git@github.com:decodableco/decodable-job-sdk.git: remote hung up unexpectedly
        at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:382)
        at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:159)
        at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:127)
        at org.eclipse.jgit.transport.Transport.push(Transport.java:1384)
        at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:137)
        ... 129 more
Caused by: java.lang.NullPointerException
        at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107)
        at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:358)

Seems like that org.eclipse.jgit.ssh.jsch dependency would need to be added?

gunnarmorling commented 1 year ago

Some more context on this one: my git remote was configured to use SSH, not HTTPS. This seems to generally be unsupported with JReleaser currently, since even when I added that dependency, things wouldn't work. It'd still try to authenticate with user name and PAT (as the UsernamePasswordCredentialsProvider is hard-coded in ReleaseUtils), instead of using key-based authentication.

IMO, the best solution to all this would be to use the native git installation (by launching an external process) instead of using jgit. Then I should be able to use key-based auth, with the key passphrase being retrieved from my SSH agent. Another issue with jgit is that the jsch dependency isn't actively maintained, so newer key formats like ed25519 aren't supported.

I got unstuck by changing my remote to use HTTPS, I think it's worth calling out in the docs that SSH isn't supported atm.? And/or fail eagerly with a descriptive error message when detecting that SSH is used.

aalmiray commented 1 year ago

Failing quickly when SSH is configured as protocol sounds like a quick win we should support right away.

Switching to external git command will take more effort but it's feasible.

haydenbaker commented 8 months ago

Edge case here - only realized the problem was SSH after I found this issue. I had git configured to globally use ssh instead of https, which I feel is fairly common. It would be a good idea to call this out in the docs, or more specifically, the checklist. Thanks!

aalmiray commented 8 months ago

FWIW regarding the state of jsch 👇 https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/68bd2c146239b87d355ed6169ca0ec227a69995d/org.eclipse.jgit.ssh.jsch/

JGit SSH support via JSch

This bundle provides an implementation of git transport over SSH implemented via JSch.

This bundle should be considered deprecated. It is essentially unmaintained, and the JGit project may decide anytime to remove it completely without further ado.

The officially supported SSH transport is in bundle org.eclipse.jgit.ssh.apache and is built upon Apache MINA sshd.