0


jenkins添加git凭证

插件管理

需要一下插件支持
在这里插入图片描述在这里插入图片描述

在凭据管理中添加全局凭证

在这里插入图片描述

方式一: SSH认证

生成sshkey
终端输入

ssh-keygen -t rsa -C '[email protected]'

一路回车

jenkins@jenkins-0:/$ ssh-keygen -t rsa -C 'root@git'
Generating public/private rsa key pair.
Enter file in which to save the key (/var/jenkins_home/.ssh/id_rsa): 
Created directory '/var/jenkins_home/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /var/jenkins_home/.ssh/id_rsa
Your public key has been saved in /var/jenkins_home/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:F5R4bnPjBLCUu8kUwhsoPkQnpGxIzbh72rk7xyGBz+g root@git
The key's randomart image is:
+---[RSA 3072]----+
| +B .o  o+..     |
|+oo=. +.+o+      |
|o=o.   +.=..     |
|.oo.  . o +.+    |
|  =..  oS+.= .   |
| o = .  +.  .    |
|. + + .          |
| E + o           |
|   o=            |
+----[SHA256]-----+

最终会在用户目录/.ssh/ 中生成公钥和私钥(id_rsa.pub和id_rsa)

Your identification has been saved in /var/jenkins_home/.ssh/id_rsa
Your public key has been saved in /var/jenkins_home/.ssh/id_rsa.pub
cat /var/jenkins_home/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDGx87A9X/RpZX4833l893dDveLl0W2i/G+9K3A7OufTxueeIsvvmws67iDoJbm52OUQZfUfduo1r8NEf5EQ58MJChd7kwYtGWPKWH2Qct2oDe3RJ1r141FBCs7WAaWpW3l6wLDTxaU+ndg3gYOd5+L3HEojsy+TPTRF5ZRKBaVldesuc36WfbqI6ZxmktBVm9829OGBSW/FEZ6+/Zf4Tec0d7mD/DpwY3AX5ZJtLvwjRaenK97Ht2EkJ8UlxgQZkULISR7HxM4PngWzj0wDDPXcohU/Qn2T9jLtA22JERj8mk82xbCvc6/yxSSMqfgE1oLB9nYP2S8EdHIk2wW7NyqxtJyxsunohbl0j52Ktn2/OW1kycyo+6e6hzCY64LLeHM2Kw487u9dJCtlHL5offz+i1CyPAaNFc5kL41QTcIeK2BWArNMiLv2Gojts+o3dyhO1wAJt15m8/AQCSjZaq/iG2IJHBbK0JZgdhIOXTjq/I+BtLNiOV1oR7mMt4jDxM= root@git

将id_rsa.pub内容拷贝出来,然后打开github,进入setting-> SSH and GPG keys 点击New SSH key
在这里插入图片描述
在Jenkins中添加凭证
选择SSH Username with private key认证方式
在这里插入图片描述
将cat /var/jenkins_home/.ssh/id_rsa内容粘贴到key(全部id_rsa得内容)
在这里插入图片描述

方式二: 用户名密码方式认证
选择Username with password填写你的git用户名密码同样可以
在这里插入图片描述

标签: jenkins git 运维

本文转载自: https://blog.csdn.net/li81562/article/details/139515375
版权归原作者 潞哥的博客 所有, 如有侵权,请联系我们删除。

“jenkins添加git凭证”的评论:

还没有评论