Getting "java.net.ConnectException: Connection refused" while using Jenkins plugin for Gitea as well as GitLab

huangapple go评论103阅读模式
英文:

Getting "java.net.ConnectException: Connection refused" while using Jenkins plugin for Gitea as well as GitLab

问题

在添加Gitea服务器(使用Gitea Jenkins插件)时,出现“java.net.ConnectException: Connection refused”错误,无法连接到Gitea服务器实例。因此,我认为这可能是Gitea Jenkins插件的错误,尝试了GitLab,但在添加GitLab服务器(使用GitLab分支源Jenkins插件)时仍然收到相同的错误。

我正在使用Jenkins版本2.387.3的Multibranch管道作业。

请注意,凭据是正确的,并且是根据相应插件文档中提到的步骤为Gitea(或GitLab)实例中的用户创建的API令牌。

请注意,如果我不使用Gitea(或GitLab)Jenkins插件,只选择“Git”作为分支源并提供存储库URL,配置Multibranch Pipeline时,根本不会出现此错误。

我尝试增加了Jenkins中的全局构建时间或编辑其他设置,但没有帮助。
关于Gitea Jenkins插件的注意事项,一开始它是可以工作的,但后来出现了这些错误,然后一直定期出现错误。对于GitLab插件,从一开始就出现了这些错误。

请注意,Jenkins、Gitea和GitLab都位于Linux VM服务器上(ufw)防火墙后面,已添加适当的规则。我尝试在Jenkins上禁用防火墙,突然这些错误消失了,但我在一周内没有重新开始工作,后来再次在禁用Jenkins防火墙后出现了这些错误。

英文:

On adding Gitea Server (using Gitea jenkins plugin), it does not connect to Gitea server instance giving "java.net.ConnectException: Connection refused" error.
So, I thought this might be an error of Gitea jenkins plugin and tried this for GitLab, but receiving same error, when adding GitLab Server (using GitLab Branch Source jenkins plugin).

I am using Multibranch pipeline job, on Jenkins version 2.387.3

Note that credentials are correct and created using the API token created for a user in Gitea (or GitLab) instance as per the steps mentioned in resp. plugin documentation.

Note that if I do not use Gitea (or GitLab) jenkins plugin and select simply "Git" as Branch Source and provide repository URL, while configuring Multibranch Pipeline, then this error does not appear at all.

I tried to increase the global build time or edit other settings in jenkins, but no help.
Note for Gitea jenkins plugin, it was working in start but later got these errors, and then kept on regularly getting errors. For GitLab plugin, got these errors right from beginning.

Note Jenkins, Gitea and GitLab are all behind (ufw) firewall on Linux VM servers, with proper rules added. I tried disabling firewall on jenkins and suddenly these errors were gone, but I did not start back work on it for a week and later on, again got these errors even after disabling firewall on jenkins.

Started by user admin
Looking up repository Jangoo/hello_world
java.net.ConnectException: Connection refused (Connection refused)
	at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
	at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.base/java.net.Socket.connect(Socket.java:609)
	at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:305)
	at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
	at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:507)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:602)
	at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
	at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373)
	at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:207)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
	at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:193)
	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:168)
	at org.jenkinsci.plugin.gitea.client.impl.DefaultGiteaConnection.getObject(DefaultGiteaConnection.java:860)
	at org.jenkinsci.plugin.gitea.client.impl.DefaultGiteaConnection.fetchRepository(DefaultGiteaConnection.java:200)
	at org.jenkinsci.plugin.gitea.GiteaSCMSource.retrieve(GiteaSCMSource.java:187)
	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:581)
	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:99)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:312)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:442)
Finished: FAILURE

答案1

得分: 1

我已找到此错误的原因。实际上,我使用的子域名有两个DNS记录,一个是CNAME记录(别名记录,是因为错误创建的),另一个是A类型记录(映射到服务器的IP地址)。而且我在同一台服务器上运行Gitea和GitLab时使用了特定的端口号。

CNAME DNS记录已根据我的了解被删除,但仍然有时会从某些DNS服务器中获取(即它未从DNS服务器中正确删除),这是导致此错误的原因。

我知道了这个原因,当我更改了Gitea的配置文件“app.ini”,然后在Gitea jenkins插件中添加Gitea服务器时,我将Gitea运行在服务器的裸IP地址上,这解决了错误。

我还尝试了在指向同一台服务器的不同子域名上进行此操作,该服务器只有一个DNS记录,A类型记录,这不会在添加Gitea服务器到Gitea jenkins插件时引发任何错误。无论如何,感谢@markalex。

英文:

I have found the cause of this error. Actually, the subdomain I was using has two DNS records, one as CNAME Record (alias record, which was created by mistake) and one with A type record (mapping to IP address of server). And I am using specific port numbers for running Gitea and GitLab on same server.

The CNAME DNS Record was deleted, as per my knowledge but it still sometimes got picked up from some DNS server (i.e. its not properly deleted from DNS servers) which was causing this error.

I came to know of this cause, when I ran Gitea on bare IP address of server by changing its configuration file, "app.ini" and then using the same IP address while adding Gitea server in Gitea jenkins plugin, which solved the error.

I have also tried this, with a different subdomain name pointing to same server which has only one DNS record, A type record, which does not cause any error while adding Gitea server in Gitea jenkins plugin. Thanks anyways, @markalex.

huangapple
  • 本文由 发表于 2023年8月4日 21:21:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76836327.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定