使用Java的Gitlab API连接到gitlab

时间:2018-01-08 19:19:13

标签: java git gitlab gitlab-api

我想确定哪些修改过的文件和分支与特定的哈希码相关。所以,我正在尝试使用Java的GitLabAPI(Java's Gitlab API)。

我的问题是用于实现此实现的路径。

我在互联网上看了一眼并尝试将我连接到这样的存储库:

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

但是,发生以下错误:

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)

如何连接到存储库我需要做什么?

2 个答案:

答案 0 :(得分:0)

也许这是与SSL认证相关的问题,你是否在JVM中导入了它?

我使用了另一个类似的库(https://github.com/gmessner/gitlab4j-api),在URL参数中我设置了这样的东西: https://myserver.it/gitlab

答案 1 :(得分:0)

使用“ http://”而不是“ https: 要么 gitLabApi.setIgnoreCertificateErrors(true);