Jenkins2.0的Pipeline(formerly called ‘workflow’)允许用户定义软件项目的整个生命周期来支持持续集成。在项目根目录下创建一个Jenkinsfile文件,编写从构建到部署的整个生命周期,减少了复杂的Jenkins界面操作。
Pipeline特性如下:
- 持久性(durable):在Jenkins master按计划和非计划的重启后,pipeline仍然能够工作,类似nohup
- 暂停:支持任务暂停并等待手动触发
- 灵活:Pipeline支持复杂的持续集成需求,包括fork, join, loop, work in parallel
- 扩展:支持DSL(Domain Scripting Language)并可与其他插件集成
一些跟Pipeline相关的插件:
- Pipeline: 包含了核心pipeline引擎以及其从属的插件,
Pipeline: API, Pipeline: Basic Steps, Pipeline: Durable Task Step, Pipeline: Execution Support, Pipeline: Global Shared Library for CPS pipeline, Pipeline: Groovy CPS Execution, Pipeline: Job, Pipeline: SCM Step, Pipeline: Step API
- Pipeline Stage View: 图形化的泳道阶段图
- Multibranch Pipeline: 自动构建包含
Jenkinsfile的分支
- Docker Pipeline: 在Jenkinsfile脚本中使用Docker containers进行构建
Jenkinsfile Template
deploy.sh脚本中为远程机器上执行的命令。
Stage View
Another Jenkinsfile
https://github.com/zhjwpku/ijkplayer/blob/master/Jenkinsfile
Reference:
1 Jenkins1.0版本的Workflow插件介绍: Continuous Delivery With Jenkins Workflow
2 Pipeline Overview: https://jenkins.io/doc/book/pipeline/overview/
3 Jenkinsfile: https://jenkins.io/doc/book/pipeline/jenkinsfile/
4 Pipeline Steps Reference: https://jenkins.io/doc/pipeline/steps/
5 Top 10 Best Practices for Jenkins Pipeline Plugin
6 Using the Pipeline Plugin to Accelerate Continuous Delivery — Part 1
7 Using the Pipeline Plugin to Accelerate Continuous Delivery — Part 2
8 Using the Pipeline Plugin to Accelerate Continuous Delivery — Part 3
9 Building a Continuous Delivery Pipeline with Gradle and Jenkins