Docker:pipeline编写基本技巧- jenkins配置通过免交互方式拉取git源码管理仓库的代码
工作中,从git仓库拉取代码有2种方式:交互式和非交互式
什么是交互式?就是拉取需要权限才能访问的代码时,需要输入密码

免交互式呢? 是通过密钥,私钥的方式,让服务端信任客户端,产生信任后,任何一次客户端向服务端发起的请求时,不需要密码,而是直接进行读写等操作。
在持续集成中,jenkins需要去git代码仓库拉取代码,在这个过程中不方便交互式的输入代码,所以采用免交互式会比较方便。
密钥私钥的生成和使用:
在客户机linux机器上 ssh-keygen 一路回车
[root@ ~]# ssh-keygen
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:
SHA256:llzcheb6UtbggaOnU6FTjssrLTIM5CQ5FjsnBq2zo5I root@192.168.1.40
The key's randomart image is:
+---[RSA ]----+
| . .. |
|... . .o. |
|.oo o+. |
|**o. . o= + |
|oO+ S* = + |
|o o .= = + . |
|.o o o * + |
|E + o * . . |
|. o o.o . |
+----[SHA256]-----+
[root@ ~]# ls .ssh/
id_rsa id_rsa.pub known_hosts
#通过ssh-copy-id命令将/root/.ssh/id_rsa.pub公钥copy到192.168.1.30git源码管理服务器上
[root@192 ~]# ssh-copy-id git@192.168.1.30
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
git@192.168.1.30's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'git@192.168.1.30'"
and check to make sure that only the key(s) you wanted were added.
到192.168.1.30git源码管理服务器上,查看id_rsa.pub存放到了哪里
[root@ ~]# su - git
[git@ ~]$ cat .ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDPW1GD64WQr/1WdklohJrS35i3MS7Om2m9vXlDW/ZuvuucYiSzEiI9Thr3ooPBlavLRofh/oS3xzu+jHydm9hY20IV73Kmua3BWw3eMLUT6PXs2fvpGpspx9doVmJZ6B4IGN/4VYoFUPTYpy+WxxcqkxPeMQrZ5mcemzlUkB6GcSmNEI2U0lP4z7h+H0i+JvoVd7CF7FCAiYLxsBxLFdQnJxdfvybaQ+qt6bvShqg8Ijus4rveqFSO7NRamGX4KZmvIdgVQ1uMLT5PYuC2u6F+hLhCLg7XoqzqxGtl+4kIgGedQzxxsHzxa1D7x1Hx7SsTlb9xJKJRVE89P0/KOtnf root@192.168.1.40
将客户端(jenkins)服务器的私钥配置到jenkins管理界面里,
git代码仓库拉代码的pipeline脚本产生方法

下图是上图步骤3里,点开后的配置

下图是ssh-keygen产生的私钥 .ssh/id_rsa

到此,步骤5里,就产生了pipeline脚本,免交互方式让jenkins服务器拉取git代码仓库里的代码
作者: 梅梅~
出处: https://www.cnblogs.com/keeptesting
关于作者:专注软件测试,测试运维相关工作,请多多赐教!
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 原文链接 欢迎沟通交流加微信联系。 微信:yangguangkg20140901 暗号:博客园.
Docker:pipeline编写基本技巧- jenkins配置通过免交互方式拉取git源码管理仓库的代码的更多相关文章
- 【Linux】Jenkins+Git源码管理(三)
摘要 本章介绍Jenkins配合Git源码管理,关于Jenkins的基本操作,参照[Linux]Jenkins配置和使用(二) 事例说明:在linux环境下,安装的jenkins,已安装git. 代码 ...
- Jenkins(3)拉取git仓库代码,执行python自动化脚本
前言 python自动化的脚本开发完成后需提交到git代码仓库,接下来就是用Jenkins拉取代码去构建自动化代码了 新建项目 打开Jenkins新建一个自由风格的项目 源码管理 Repository ...
- Docker: Jenkins里的pipeline编写基本技巧
Jenkins里,先新建一个pipeline项目 Pipeline Syntax 在Sample Step里选择需要的插件,如果不存在,就去系统管理,插件管理里,进行安装. 如果源码管理工具用的是gi ...
- jenkins配置源码管理git
一.首先安装上来jenkins 二.下载安装jenkins的git插件:Git plugin 三.新建一个jenkins项目,选择构建一个自由风格的软件项目: 源码管理选择git,Repository ...
- 【Devops】【docker】【CI/CD】Jenkins源码管理,设置gitlab上项目的clone地址 + jenkins构建报错:Please make sure you have the correct access rights and the repository exists.
注意,如果 jenkins构建报错:Please make sure you have the correct access rights and the repository exists. 而此时 ...
- 【Devops】【docker】【CI/CD】jenkins源码管理,添加SSH地址后报错+Jenkins构建报错:Please make sure you have the correct access rights and the repository exists.
jenkins源码管理,添加SSH地址后报错: Could not read from remote repository. Please make sure you have the correct ...
- Jenkins教程(三)添加凭据与流水线拉取Git代码
前言 本文旨在配置凭据.使用Git仓库中的Jenkinsfile与使用声明式流水线拉取Git代码 使用SVN等其他版本控制工具,请参考使用Pipeline-Syntax生成对应代码块 凭据(crede ...
- jenkins持续集成源码管理选项为None,构建失败找不到git.exe解决办法
我的jenkins版本为Jenkins ver. 2.19.1 1.源码管理选项只有None的解决办法: 在插件管理中心,搜索对应的源码管理插件这里以git为例,搜索git plugin点击右下角的安 ...
- Matlab.NET混合编程技巧之——直接调用Matlab内置函数(附源码)
原文:[原创]Matlab.NET混合编程技巧之--直接调用Matlab内置函数(附源码) 在我的上一篇文章[原创]Matlab.NET混编技巧之——找出Matlab内置函数中,已经大概的介绍了mat ...
随机推荐
- Sql中CHARINDEX用法
CHARINDEX作用 写SQL语句我们经常需要判断一个字符串中是否包含另一个字符串,但是SQL SERVER中并没有像C#提供了Contains函数,不过SQL SERVER中提供了一个叫CHAEI ...
- 使用async await 封装 axios
异步变同步: 厉害-- https://www.jianshu.com/p/4168efdc172b
- IIS Express 配置缓存位置
Please refer to the three configure files to check if they contains the rule setting. "%Program ...
- ES 07 - Elasticsearch查询文档的六种方法
目录 1 Query String Search(查询串检索) 2 Query DSL(ES特定语法检索) 3 Query Filter(过滤检索) 4 Full Text Search(全文检索) ...
- C#利用NPOI操作Excel文件
NPOI作为开源免费的组件,功能强大,可用来读写Excel(兼容xls和xlsx两种版本).Word.PPT文件.可是要让我们记住所有的操作,这便有点困难了,至此,总结一些在开发中常用的针对Excel ...
- .netcore 模块积累
最全的 demo https://github.com/XiaoFaye/netcore-samples http://files.cnblogs.com/files/kellynic/practic ...
- 从QA到工程能效团队
Engineering Productivity Productivity is our job; testing and quality are the job of everyone involv ...
- springboot源码分析-SpringApplication
SpringApplication SpringApplication类提供了一种方便的方法来引导从main()方法启动的Spring应用程序 SpringBoot 包扫描注解源码分析 @Spring ...
- Spring中关于AOP的实践之Scheme方式实现通知
(刚开始写东西,不足之处还请批评指正) 关于AOP的通知编写方式有两种,使用Schema-baesd或者使用AspectJ方式,本篇主要介绍Schema-baesd方式的代码实现. (注:代码中没有添 ...
- Python二级-----------程序冲刺4
1. 根据输入正整数 n,作为财务数据,输出一个宽度为 20 字符,n 右对齐显示,带千位分隔符的效果,使用减号字符“-”填充.如果输入正整数超过 20 位,则按照真实长度输出.提示代码如下: ...