Connect to gitlab using Java's Gitlab API

2019-08-20 06:53发布

I want to identify which modified files and branch are related to a specific hash code. So, I am trying to use the Java's GitLabAPI (Java's Gitlab API) for this.

My question is Which path to use to make this implementation.

I took a look on the Internet and tried connect me with repository like this:

GitlabSession session = GitlabAPI.connect(host, "user", "key");
GitlabAPI api = GitlabAPI.connect(host, session.getPrivateToken());

However, the following error occurred:

16:03:17,080 ERROR [STDERR] java.net.SocketException: Connection reset
16:03:17,081 ERROR [STDERR]     at java.net.SocketInputStream.read(Unknown Source)
16:03:17,081 ERROR [STDERR]     at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source)
16:03:17,081 ERROR [STDERR]     at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
16:03:17,081 ERROR [STDERR]     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
16:03:17,081 ERROR [STDERR]     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
16:03:17,081 ERROR [STDERR]     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
16:03:17,081 ERROR [STDERR]     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
16:03:17,081 ERROR [STDERR]     at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
16:03:17,081 ERROR [STDERR]     at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
16:03:17,081 ERROR [STDERR]     at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
16:03:17,081 ERROR [STDERR]     at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
16:03:17,081 ERROR [STDERR]     at org.gitlab.api.http.GitlabHTTPRequestor.submitData(GitlabHTTPRequestor.java:339)
16:03:17,081 ERROR [STDERR]     at org.gitlab.api.http.GitlabHTTPRequestor.to(GitlabHTTPRequestor.java:160)
16:03:17,081 ERROR [STDERR]     at org.gitlab.api.http.GitlabHTTPRequestor.to(GitlabHTTPRequestor.java:139)
16:03:17,081 ERROR [STDERR]     at org.gitlab.api.GitlabAPI.connect(GitlabAPI.java:54)

What do I have to do to get connected to the repository?

1条回答
Emotional °昔
2楼-- · 2019-08-20 07:04

Maybe it's a problem related to the SSL certifcate, did you imported it in you JVM?

I used another similar library (https://github.com/gmessner/gitlab4j-api) and in the URL parameter i set something like this: https://myserver.it/gitlab

查看更多
登录 后发表回答