一 本地git 服务安装配置
1. 在192.168.8.108 centos 7.3.1611 安装git 软件
yum -y install git useradd git echo ‘qweasd’ | passwd –stdin git mkdir /git/reps -p && cd /git/reps git init --bare jenkins_pipeline.git chown -R git.git jenkins_pipeline.git usermod -s /usr/bin/git-shell git
2. 客户端192.168.8.106 机器进行clone 测试
git clone git@192.168.8.108:/git/reps/jenkins_pipeline.git # 可以新建一个文件进行测试 cd Jenkins_pipeline.git && echo ‘test file’ > aa.log git add . git commit -m ‘注释说明’ git push -u origin master # 一定要加上 -u origin master ##### 测试连接情况 ssh -T -v git@192.168.8.108
二. 配置pycharm 编辑器进行编辑
首先右键file => 选择setting => 找到version control => git
点击file => CloseProject 关闭这个项目,接着配置新项目
Clone 完代码就能进行编写 pipeline Jenkinsfile了。
三. Jenkins 配置pipeline 代码
1. 在jenkins 中配置 git 认证
git 私钥认证
# ssh-keygen # 生成id_rsa id_rsa.pub # 使用 命令把 id_rsa.pub 拷贝到192.168.8.110机器的authorized_keys 文件中 # ssh-copy-id 192.168.8.110
2. 配置jenkins pipeline 项目进行配置
这样就可以在pycharm 中编写pipeline 文件了。