[root@node1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
bf:1e:4d:b3:0f:fb:8b:71:cd:ef:d3:70:69:a4:46:ff root@node1.chinasoft.com
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| |
| . . |
| S + + .|
| . o =.*.|
| o * oo=|
| o B .E|
| .o o.+o+|
+-----------------+
[root@node1 ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3vhfbA4NdkP8g1WVyYkw93f1PZ04nWoyFnoerC9b40jIY5px+tkugdy/RZ3/bp4hMC5yNgV1S25Tm8RpzBJMp7pbJz8dO+LCKqUnXq9Eh0QhsZE0xlQN+J4awy9YIGiD2nFg7k/ZzeAtQRzNryrrPnKaWpXtg7tMGGTWBjeyLAVuqCOMU7euY94G26UmVfjDLIJkcJqB+8dwvodW3wpmUER32qVPKZLnSYSOCfoNed+P4Eujs5PBCLuzFvGyiDhY2Pwrk/4S11jWUa7TJItfoPXzeGc/ujaJi/o24dt8VXeFa/Rm4wywYLNW3TRjXy1mPpdVlob3701MMQ0bf3qPv root@node1.chinasoft.com
gitlab上配置web-demo项目设置private deploy key
把key复制进去,同时title起一个简单明了的名字
在jenkins服务器192.168.3.199上测试下是否能够正常获取代码
[root@node1 tmp]# git clone git@192.168.3.198:web/web-demo.git
Cloning into 'web-demo'...
The authenticity of host '192.168.3.198 (192.168.3.198)' can't be established.
ECDSA key fingerprint is 9d:60:c3:8e:49:72:e8:9c:c0:d6:c8:d2:f1:b6:3a:74.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.3.198' (ECDSA) to the list of known hosts.
remote: Counting objects: 79, done.
remote: Compressing objects: 100% (79/79), done.
remote: Total 79 (delta 17), reused 0 (delta 0)
Receiving objects: 100% (79/79), 1.18 MiB | 0 bytes/s, done.
Resolving deltas: 100% (17/17), done.
jenkins拉取代码没问题,继续配置jenkins的认证,这里应该输入私钥
复制jenkins拉取git代码服务器root的私钥
[root@node1 ~]# cat .ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAt74X2wODXZD/INVlcmJMPd39T2dOJ1qMhZ6HqwvW+NIyGOac
frZLoHcv0Wd/26eITAucjYFdUtuU5vEacwSTKe6Wyc/HTviwiqlJ16vRIdEIbGRN
MZUDfieGsMvWCBog9pxYO5P2c3gLUEcza8q6z5ymlqV7YO7TBhk1gY3siwFbqgjj
FO3rmPeBtulJlX4wyyCZHCagfvHcL6HVt8KZlBEd9qlTymS50mEjgn6DXnfj+BLo
7OTwQi7sxbxsog4WNj8K5P+EtdY1lGu0ySLX6D183hnP7o2iYv6NuHbfFV3hWv0Z
uMMsGCzVt00Y18tZj6XVZaG9+9NTDENG396j7wIDAQABAoIBAEHMfCR9HJTsMMDk
SmDs3JqnHWhK+UzUe0/6VmEla0VNmI0cQFyMEYcUR3Z41uulEgURf22ZLv9WDPuq
yar4r26rtynsE1avbiEpwHzQVaMDhT2zqYUg9NA/fVdgl3PtT3KgyGQFd5MgIQUN
ileGkOF6GpoGBqnOvJkJfAS5+0RHi8EZ8RcufNExgan5QF42dtKNWOEdgZIp0+WY
jmI73YEpIadQzKxjL6PCOUmFAjfuNllw3It5QLePvYYlQeWKkl8QdROOADzOxgoj
6zCdzGo6ZqP4vK8gGioT7UybH1WJoN8of1ZBenKyT4+TagQYwqV0LXIpVBkHKgdD
5bxZIPkCgYEA4giWHweLYxmkZIXDx5VrOjIPmzTFqSfDMI9rDFQt57AbIr0hM4BW
6qmViWwuc9t28cLSXv+0FtycIfs4co8RvMinIMLykWddX8x3sniCr2+Pgn/G+RgQ
FK36wN0dVZwwr/6oPeIDCJlr4AqhDAJLJkcbRjc5i8kR9OPHIvkPJjsCgYEA0Bou
cmeOGYtrCW6t88xnmR26Sk8ybNWUdpju9SpEeCdz4jJnZC29AJ3qg8LilG0sDS/y
0cNT/iMP8x6FPeFqJnhI/l4C1H5WEqult/thMl1bZ+RFEO92EUcKEXZep0yu5Txr
6bHZzCnp9cYe56z9qsGk064LR2N9TR16xAzeud0CgYEArx0B2NZKeaNDBhHPxI8Q
/IwOJSs0O0Gv6a4iu/F3gviffUFTOIgkTjbFwCqMrnuHYfOSccDeb5vIZlcvuyj2
D/DP8gS2UknnQDGzRhQxAuOGJg8CQrcOtka3brWfZVTVL3Q2OYMg4Iej2HXDoP8h
42zRR4u/THmhLL1O6NxVjUMCgYBslKyVbuja9T61HjXPVmDbqIIyEZ6a4NnlA6jy
7Mnq85LofCosQB00vDDH7SCyF0B75P/KaSNjH8JLtSoKfpoXVn2nkz/gxcZ9WWhP
Ve+CCuoNjDJpQriVDT74m42Jt14uJ9eaiPy+JUR4w5YOhdmZhg5NkKs75XJUkUQk
FR8FVQKBgQDOWXJYF3VEYdCD1qIy/CsY3s4ARD9kery+5aOCu6TNd6auYEfqxsev
ie1jD+cvAgVR1aZ5aP3C8jEYhZa4xgn1+hxfRLWs79uMYnXXNGJ+FxKftDyhuV+m
efEQrUf8jh4MofW9Ee6Z7YjitIRY7SQ+kZl2Xms+QZlJotBzTG2DSA==
-----END RSA PRIVATE KEY-----
添加描述,点击OK
继续编辑配置
这样就不报错了,下面还可以指定从哪个分支拉取,默认从master拉取,有些公司使用release分支
源码浏览器,去gitlab上找到http的url:
找出gitlab的版本,输入url和版本,版本只支持2位,拉到最下面保存
[root@web01 ~]# rpm -qa|grep gitlab
gitlab-ce-8.10.5-ce.0.el7.x86_64
点击立即构建,查看控制台,可以看到构建的详细输出