当前位置:网站首页>《Jenkins 2.x实践指南》读书笔记-Jenkins 2.x简介和pipeline示例
《Jenkins 2.x实践指南》读书笔记-Jenkins 2.x简介和pipeline示例
2022-08-06 10:00:00 【ygqygq2】
文章目录
1. Jenkins 2.x简介
1.1 pipeline是什么
从某种抽象层次上讲,部署流水线(Deployment pipeline)是指从软件版本控制库到用户手中这一过程的自动化表现形式。——《持续交付——发布可靠软件的系统方法》(下称《持续交付》)
按《持续交付》中的定义,Jenkins本来就支持pipeline(通常会把部署流水线简称为pipeline,本书会交替使用这两个术语),只是一开始不叫pipeline,而叫任务。
Jenkins 1.x只能通过界面手动操作来“描述”部署流水线。Jenkins 2.x终于支持pipeline as code了,可以通过“代码”来描述部署流水线。
使用“代码”而不是UI的意义在于:
- 更好地版本化:将pipeline提交到软件版本库中进行版本控制。
- 更好地协作:pipeline的每次修改对所有人都是可见的。除此之外,还可以对pipeline进行代码审查。
- 更好的重用性:手动操作没法重用,但是代码可以重用。
本书全面拥抱pipeline as code,放弃依赖手动操作的自由风格的项目(FreeStyle project)。
1.2 Jenkinsfile又是什么
Jenkinsfile就是一个文本文件,也就是部署流水线概念在Jenkins中的表现形式。像Dockerfile之于Docker。所有部署流水线的逻辑都写在Jenkinsfile中。
1.3 pipeline语法的选择
Jenkins pipeline有2种语法:脚本式(Scripted)语法和声明式(Declar-ative)语法。
脚本式语法使用Groovy语言,其语法灵活、可扩展,但是也意味着更复杂。再者,Groovy语言的学习成本对于(不使用Groovy的)开发团队来说通常是不必要的。所以才有了声明式语法,一种提供更简单、更结构化(more opinionated)的语法。
- pipeline插件从2.5版本开始,才同时支持两种格式的语法;
- 推荐主要使用声明式语法,脚本式语法作为辅助;
1.4 pipeline版本控制化
为了便于维护和协作,使用版本仓库对pipeline进行版本控制是生产使用过程中的最优选择。
本人实践过程中也是推荐书中提到的使用Git作为版本控制仓库,使用Jenkins ssh私钥作为凭证。

2. 利用github仓库pipeline进行构建
以下为本实验地址:
https://github.com/ygqygq2/jenkins2_learning_install_tools
目的
使用jenkins拉取git仓库内pipeline构建maven项目,达到了解pipeline基本用法。
环境
- github仓库
- jenkins(已整合kubernetes)
实践
- 进入Manage Jenkins→Global Tool Configuration->Maven页添加
mvn-3.5.4

- 进入Manage Jenkins→Global Tool Configuration→JDK页添加
jdk-8u172

注意这里需要oracle帐户验证。
添加pipeline项目

构建
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-j9kDMApF-1571912834590)
因为jenkins-slave是整合kubernetes的,因此每次构建都会安装tools,如上图可以看出,maven安装包需要从官方下载,这对效率影响非常大。
若想优化可以考虑jenkins-slave镜像中直接整合maven,而不是使用jenkins tools;还可以使用docker-in-docker配合maven镜像。
边栏推荐
- Kotlin进阶指南 - default constructor not found
- B. Luke is a Foodie(贪心/模拟)
- UE5 使用Mesh Editor 查看骨骼相对于root的坐标系
- 简单相机跟随
- Redis是单线程吗?以及为什么使用单线程(Redis 的网络模型)
- Let's talk about the pits of mysql's unique index, why does it still generate duplicate data?
- 深度神经网络
- 亚马逊员工教你打造DIY版Echo
- Hongke Sharing|How to ensure the security of medical data?Moving target defense technology gives you satisfactory answers
- 使用IPv6 Minecraft开服(无需外网穿透,经济、免费)
猜你喜欢

DO280管理和监控OpenShift平台--OCP升级

【Untitled】

C语言实现扫雷

jupyter notebook & pycharm (anaconda)

Advanced Integrated Learning

View the Linux log on the web side, and view the Linux log on the web side

Introduction to TensorFlow
![[Nanny-level tutorial] How does Tencent Cloud obtain secretId and secretKey, and enable face service](/img/8c/965e2942894299185724b315f6ca6c.jpg)
[Nanny-level tutorial] How does Tencent Cloud obtain secretId and secretKey, and enable face service

Domain name authorization verification system v1.0.6 open source version website source code

【数学建模】线性规划
随机推荐
PyBind11踩坑笔记
【机器学习】决策树
[Pyqt5 pop-up dialog]
[mysql chapter - advanced chapter] index
Day and night double-color navigation WordPress theme template navigation template
昼夜双色导航主题模板 WordPress导航模板
数组里的值放到另一个数组中,并转大写
Looking back at ResNet - a key step in the history of deep learning
B. Luke is a Foodie(贪心/模拟)
A. Two 0-1 Sequences (greedy)
pyqt5做了一个无线网连接器,与君共勉
Smart three-piece - nanny-level teaching.
View the Linux log on the web side, and view the Linux log on the web side
《Jenkins 2.x实践指南》读书笔记-Jenkins 2.x pipeline语法
ArrayList 的扩容机制
LeetCode-622. 设计循环队列
智能三子棋——保姆级教学。
在线音乐播放项目——BY音乐
C语言实现扫雷
[QNX Hypervisor 2.2用户手册]10.7 vdev pci-dummy