1. 安装Jenkins
最近不知道为啥,根据官网Linux安装Jenkins的时候下不来安装包,提示连接超时。尝试多次无果后决定在window上安装
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
curl: (7) Failed to connect to pkg.jenkins.io port 443: Connection timed out
1.1.下载了一个jenkins.msi
安装步骤 Windows
安装到这步的时候,由于公司电脑权限问题我无法打开“Local Security Policy” 导致无法继续安装。
1.2. 下载war包安装
大家如果装的是java8, 建议可以下载老一点的版本,比如2.2xx, 最新版用的是java11,不兼容。
下载地址:jenkins.war
安装步骤:WAR files
贴上内容:
The Jenkins Web application ARchive (WAR) file can be started from the command line like this:
-
Download the latest Jenkins WAR file to an appropriate directory on your machine
-
Open up a terminal/command prompt window to the download directory
-
Run the command
java -jar jenkins.war
-
Browse to
http://localhost:8080
and wait until the Unlock Jenkins page appears -
Continue on with the Post-installation setup wizard below
Notes:
-
This process does not automatically install any specific plugins. They need to installed separately via the Manage Jenkins > Manage Plugins page in Jenkins.
-
You can change the port by specifying the
--httpPort
option when you run thejava -jar jenkins.war
command. For example, to make Jenkins accessible through port 9090, then run Jenkins using the command:java -jar jenkins.war --httpPort=9090
有时候因为公司代理可能没法安装插件:可以通过Manage Jenkins ->Plugin Manager->Advanced->HTTP Proxy Configuration 配置好代理就可以了。
配置job的时候可以使用这个方式模拟sleep
echo "---start---"
ping 127.0.0.1 -n 5 -w 1000 > nul
echo "---end---"
好啦,Jenkins安装成功啦。
2.在ruby环境中调用Jenkins
可以看到我连接超时
2.6.5 :005 > client
=> #<JenkinsApi::Client:0x562208267200 @ssl=false, @log_location=#<IO:<STDOUT>>, @log_level=1, @crumbs_enabled=nil, @follow_redirects=nil, @jenkins_path="", @timeout=120>, @http_open_timeout=10>, @http_read_timeout=120>
2.6.5 :004 > client.api_get_request("")
Traceback (most recent call last):
1: from (irb):4
Net::OpenTimeout (execution expired)
使用下面命令测一下正常
traceroute 10.x.x.x -p 8080
后来发现设置代理后可以正常访问
http_proxy=http://代理IP:8080 rails c