0

詹金斯2.82连接到events.pagerduty.com:443进行连接超时

詹金斯主 - 从这个机器,我没有接入互联网/外面的世界。

Jenkins从属服务器,运行码头容器(用于从属服务器),确实可以访问外部世界/互联网。

我安装了PagerDuty插件,并在作业中正确配置它以发送每次失败通知以及状态恢复正常时的通知。

当我运行该作业时,出现以下错误信息com.mashape.unirest.http.exceptions.UnirestException: org.apache.http.conn.ConnectTimeoutException: Connect to events.pagerduty.com:443 [events.pagerduty.com/54.244.255.45, events.pagerduty.com/54.241.36.66, events.pagerduty.com/104.45.235.10] failed: connect timed out

0:49:44 
10:49:44 Resolving incident 
10:50:14 Error while trying to resolve 
10:50:14 com.mashape.unirest.http.exceptions.UnirestException: org.apache.http.conn.ConnectTimeoutException: Connect to events.pagerduty.com:443 [events.pagerduty.com/54.244.255.45, events.pagerduty.com/54.241.36.66, events.pagerduty.com/104.45.235.10] failed: connect timed out 
10:50:14 Build step 'PagerDuty Incident Trigger' marked build as failure 
10:50:14 Notifying upstream projects of job completion 
10:50:14 Finished: FAILURE 

我先登录到从属机器,并尝试ping IP到events.pagerduty.com服务器(如上所列)旁边,ping工作正常。在端口443上执行telnet(ssh)也提供了有效的输出。

因为从属服务器实际上是码头集装箱,所以我进入了一个容器从属服务器,并做了同样的事情(ping,telnet在443上为这些 events.pagerduty.com IPs,nslookup和nc/ncat等输出看起来不错)。

这里,林泊坞窗从容器的主机即内我跑docker exec -it shenazi_ninza bash和我现在容器的主机/ IP内:在詹金斯作业的配置

[email protected]:/data# hostname                               
da5ca3fef1c8 
[email protected]:/data# hostname; hostname -i                            
da5ca3fef1c8 
172.17.137.77 
[email protected]:/data# nslookup events.pagerduty.com                          
Server:  17.178.6.10 
Address: 17.178.6.10#53 

Non-authoritative answer: 
events.pagerduty.com canonical name = events.gslb.pagerduty.com. 
Name: events.gslb.pagerduty.com 
Address: 54.241.36.66 
Name: events.gslb.pagerduty.com 
Address: 54.245.112.46 
Name: events.gslb.pagerduty.com 
Address: 104.45.235.10 

[email protected]:/data# 
[email protected]:/data# for s in `nslookup events.pagerduty.com|grep "Address: [0-9]"|sed "s/ //g"|cut -d':' -f2`; do echo Server: $s; telnet $s 443; done 
Server: 54.245.112.46 
Trying 54.245.112.46... 
Connected to 54.245.112.46. 
Escape character is '^]'. 
^] 
telnet> quit 
Connection closed. 
Server: 104.45.235.10 
Trying 104.45.235.10... 
Connected to 104.45.235.10. 
Escape character is '^]'. 
^] 
telnet> quit 
Connection closed. 
Server: 54.241.36.66 
Trying 54.241.36.66... 
Connected to 54.241.36.66. 
Escape character is '^]'. 
^] 
telnet> quit 
Connection closed. 
[email protected]:/data# for s in `nslookup events.pagerduty.com|grep "Address: [0-9]"|sed "s/ //g"|cut -d':' -f2`; do echo Server: $s; telnet $s 443; done 
Server: 54.245.112.46 
Trying 54.245.112.46... 
Connected to 54.245.112.46. 
Escape character is '^]'. 
^] 
telnet> quit 
Connection closed. 
Server: 54.241.36.66 
Trying 54.241.36.66... 
Connected to 54.241.36.66. 
Escape character is '^]'. 
^] 
telnet> quit 
Connection closed. 
Server: 54.244.255.45 
Trying 54.244.255.45... 
Connected to 54.244.255.45. 
Escape character is '^]'. 
^] 
telnet> quit 
Connection closed. 
[email protected]:/data# ^C 
[email protected]:/data# nc -v -w 1 events.pagerduty.com 443 
Connection to events.pagerduty.com 443 port [tcp/https] succeeded! 
[email protected]:/data# 

PagerDuty整合下提供POST Built Actions区域。

我的问题是,是不是从属服务器上运行的整个作业(又名容器的奴隶从哪里我可以访问外部世界,我能够连接到events.pagerduty.com服务器)?

Jenkins似乎在POST Build Data部分下运行任何东西,在Jenkins实例中,我无法访问events.pagerduty.com(ping/telnet等)?由于我们不希望詹金斯掌握外部世界的访问权限,因此如何解决此问题,以便在该作业的构建失败时可以收到警报?

回答

0

那么,而不是打开所有访问,添加路由使用给定网关/路由仅访问events.pagerduty.com服务器

/sbin/route add -net 50.0.0.0/8 x.x.x.x dev eth0 
/sbin/route add default gw x.y.z.someIP 
/sbin/route add -net 50.0.0.0 netmask 255.0.0.0 gw x.y.z.ip 

现在从主詹金斯,我能看到/只需访问events.pagerduty.com服务器/它是IP。

x.y.z.ip是你必须要做的。