[root@jenkins ~]# ssh-keygen -t rsaGeneratingpublic/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa):Enter passphrase (empty forno passphrase):Enter same passphrase again:Your identification has been saved in/root/.ssh/id_rsa.Yourpublic key has been saved in/root/.ssh/id_rsa.pub.The key fingerprint is:SHA256:IUQIuu0SAdSbZvENbIjFYTrUrnuqKGBmZtwPj6lvz60 root@jenkinsThe key's randomart image is:+---[RSA 2048]----+|ooB=+oo ||ooo*.=||oo.*+.||+.*. o .||+* S ||.@ o ||O o *||oo =.o.||=o*..E..|+----[SHA256]-----+
[root@jenkins ~]# yum install git -y[root@jenkins ~]# git clone git@106.14.10.124:dev01/sample.git正克隆到'sample'...The authenticity of host '106.14.10.124 (106.14.10.124)' can't be established.ECDSA key fingerprint is SHA256:bO22/HlgAAGXi9CXTxDE6wvNCUcTs2OajL9PinZMN/0.ECDSA key fingerprint is MD5:ec:4f:14:0a:b6:72:cf:6e:da:5b:fa:5b:be:b9:2f:db.Are you sure you want to continue connecting (yes/no)? yesWarning:Permanently added '106.14.10.124'(ECDSA) to the list of known hosts.remote:Enumerating objects:6,done.remote:Counting objects:100%(6/6),done.remote:Compressing objects:100%(4/4),done.remote:Total6(delta 0), reused 0(delta 0), pack-reused 0接收对象中:100%(6/6),done.
如上,ssh-key已生效
配置jenkins自动拉取代码
1.jenkins 服务器添加证书 系统配置——》Manage Credentials
-w1617
系统配置——》Manage Credentials——》Jenkins——》全局凭证——》添加凭证
-w1617
这样的话Jenkins服务器拉取GitLab的代码就不需要再进行认证了。
Jenkins安装GitLab插件
1.安装插件 插件名称:
•GitLab•Gitlab Hook•Gitlab Authentication•GitLab Logo