配置ssh-key
如下配置,jenkins服务器上root用户生成密钥对

[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

在gogs配置公钥

在jenkins服务器上测试下是否能够正常获取代码 

[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出现ERROR:error cloning remote repo ‘origin解决方案(设置Global Tool Configuration)

选择Manage jenkins

点击Global Tool Configuration,设置git的路径

备注:

查看git路径方法,终端输入which git查看

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐