服务器环境:

Linux版本:CentOS Linux release 7.3.1611 (Core)

Git版本:git version 1.7.1

Git端口:22

1.安装Jenkins

(1)首先要先添加Jenkins源:

sudo wget -O /etc/yum.repos.d/jenkins.repo http://jenkins-ci.org/redhat/jenkins.repo

sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

(2)添加完成之后直接使用yum命令安装Jenkins:

yum install jenkins

(3)修改Jenkins端口及运行身份

vim /etc/sysconfig/jenkins

记一次Jenkins配置Git的过程

(4)启动 / 停止Jenkins

service jenkins start / stop

(5)在浏览器中访问Jenkins界面,http://192.168.12.12:8880

2.创建项目(省略)

3.配置Git

使用ssh协议,搭配公钥

注意⚠️:url为ssh://[email protected]:port/gitPath/projectName

Git在非默认端口,需要添加.git后缀,url为 ssh://[email protected]:8023/git/test.git

Git在默认22端口,则url为 ssh://[email protected]:22/git/test

在Jenkins服务器上生成SSH Key

cd ~/.ssh

ssh-****** -t rsa -C "[email protected]",一直回车,会生成一对文件(id_rsa , id_rsa.pub),id_rsa为私钥,id_rsa.pub为公钥

需要在Git服务器上的~/.ssh/authorized_keys文件中添加Jenkins服务器上生成的公钥

Credentials选择SSH认证方式

Username与url中user保持一致

Key为Jenkins服务器上生成的私钥

 

记一次Jenkins配置Git的过程

记一次Jenkins配置Git的过程

 

相关文章:

  • 2022-12-23
  • 2021-10-18
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2021-10-25
猜你喜欢
  • 2021-05-06
  • 2021-06-02
  • 2021-06-27
  • 2021-09-03
  • 2021-06-15
  • 2022-03-02
相关资源
相似解决方案