前提
Linux服务器上,已安装好Jenkins和gitlab,安装步骤见
https://blog.csdn.net/weixin_39648534/article/details/115839531
注意点1
在Jenkins上面构建Git源码时,
特别是通过域名访问gitlab时,注意即使Jenkins和gitlab装在同一台服务器上,也要开放22端口给Jenkins,即将Jenkins所在服务器的公网IP加入 22端口安全组中(该端口权限全放开的就当我啥也没说),不然会连接不上,报如下错误:
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@xx.xx.xx:root/store-pc.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: ssh: connect to host xx.xx.xx port 22: Connection timed out
fatal: Could not read from remote repository.
远程ssh访问gitlab服务器时,默认访问登录端口22
注: 并不需要额外配置~/.ssh/config 文件
以下两个ssh远程访问测试命令,好用收藏
ssh -T git@xx.xx.xx
ssh -vT git@xx.xx.xx