SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
Jenkins Pipeline 簡介
qrtt1
#快講
什麼是 Pipeline
• Delivery Pipeline (from Continuous Delivery)
• Jenkins Workflow Plugins
• Job Workflow Pipeline
• Pipeline 由多個 Step 組成,並且⽀支援 Pause/Resume
• Pipeline 內的狀態必需可序列化 (Serializable)
• 或宣告為不必列⼊入狀態 @NonCPS 的 function
為什麼是 Pipeline
• 依然是 Jenkins Job 的⼀一種,依然很 FreeStyle。
• 為的是 Pipeline as Code
• 它是 groovy DSL (domain specific language)
版本控制
比 FreeStyle 更 FreeStyle
Pipeline DSL
• Jenkins 的 Pipeline 介紹

https://jenkins.io/solutions/pipeline/
• Pipeline 寫作教學

https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md
• Pipeline 設計說明

https://github.com/jenkinsci/workflow-cps-plugin/blob/master/README.md
• Pipeline Steps Reference

https://jenkins.io/doc/pipeline/steps/
• Pipeline 最佳實踐

https://www.cloudbees.com/blog/top-10-best-practices-jenkins-pipeline-plugin
主要看這個
遇到問題查這個
建⽴立 Pipeline Job
• Pipeline Script from in-place editor
• Pipeline Script from SCM
• Multi-branch Pipeline (from SCM)
推薦使用 SCM 的方式
適合單 1 專案,不同階段的 Pipeline 自動建立
僅推薦應用於證驗 Script 語法
建⽴立 Pipeline 的⽅方式
• Pipeline Script Editor
建⽴立 Pipeline 的⽅方式
• Pipeline Script from SCM
Pipeline 規劃
SCM Checkout
WarBuild Test
SCM Commit
DeployRelease
Pipeline Script DEMO/Overview
Steps: node, stage, echo
node {
stage ('checkout') {
echo 'checkout from git'
}
stage ('build') {
echo 'build'
}
// … skip …
}
在哪一台機器跑 哪一個階段
做些什麼
Steps: git
stage ('checkout') {
echo 'checkout from git'
git url: 'https://my-scm/path/my-project.git'
branch: 'master'
}
optional
Steps: dir, pwd, sh (bat)
dir ('project') {
pwd()
stage ('build') {
sh """gradle clean build"""
}
stage ('test') {
sh """gradle check"""
}
// … skip …
}
Steps: step, archiveArtifacts
stage ('archive') {
step([$class: 'ArtifactArchiver', 

artifacts: "build/**/*.war", 

fingerprint: true])
}
stage ('archive') {
archiveArtifacts 

artifacts: "build/**/*.war", 

fingerprint: true
}
舊的寫法
新的寫法
requires Jenkins 2.2+ with newer plugins
Refactoring Pipeline
• 使⽤用 Function 合併多個 steps 為⼀一個有意義的動作
• 實作新的 Pipeline Step
• 使⽤用 Pipeline Shared Libraries
你瘋了嗎?
無法跨 Pipeline Script 使用
只能推惹!
https://github.com/jenkinsci/workflow-cps-global-lib-plugin
https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Shared+Groovy+Libraries+Plugin
Pipeline Shared Library
• 使⽤用⽅方法
• 啟⽤用 Jenkins ssh (因為 Jenkins 內建的 git repo ⺫⽬目前僅能 ssh auth)
• 安裝 Plugin (id: workflow-cps-global-lib)
• 使⽤用 git 指令 commit & push 提交 Shared Library 並在 Pipeline
Script 開始使⽤用
https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+SSH
web console 搜尋 plugin 找不到,用 cli 直接按裝吧!
Pipeline 使⽤用⼼心得
• Pipeline as Code 可以⽅方便版本管理
• 內建的 Pipeline Step 不夠多,得常得依賴 sh 或 bat 呼叫外部指令。
• 間接使⽤用 DevOps Tool 處理
• Ansible, Chef, Puppet
• Ant, Maven, Gradle
Q & A

Weitere ähnliche Inhalte

Was ist angesagt?

Scrum gathering 2012 shanghai 精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 shanghai  精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)Scrum gathering 2012 shanghai  精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 shanghai 精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
LetAgileFly
 
Yet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom upYet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom up
Wen-Tien Chang
 
Wot2013云计算架构师峰会 -陈轶飞2
Wot2013云计算架构师峰会 -陈轶飞2Wot2013云计算架构师峰会 -陈轶飞2
Wot2013云计算架构师峰会 -陈轶飞2
dotCloud
 

Was ist angesagt? (20)

用 Docker 改善團隊合作模式
用 Docker 改善團隊合作模式用 Docker 改善團隊合作模式
用 Docker 改善團隊合作模式
 
Docker Compose
Docker ComposeDocker Compose
Docker Compose
 
DevOps Taiwan CICD Pipeline Tools
DevOps Taiwan CICD Pipeline ToolsDevOps Taiwan CICD Pipeline Tools
DevOps Taiwan CICD Pipeline Tools
 
Docker基礎
Docker基礎Docker基礎
Docker基礎
 
Docker Build
Docker BuildDocker Build
Docker Build
 
Git flow 與團隊合作
Git flow 與團隊合作Git flow 與團隊合作
Git flow 與團隊合作
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer Talk
 
Build your ETL job using Jenkins - step by step
Build your ETL job using Jenkins - step by stepBuild your ETL job using Jenkins - step by step
Build your ETL job using Jenkins - step by step
 
Scrum gathering 2012 shanghai 精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 shanghai  精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)Scrum gathering 2012 shanghai  精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 shanghai 精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
 
Rancher 快速打造叢集的解決方案
Rancher 快速打造叢集的解決方案Rancher 快速打造叢集的解決方案
Rancher 快速打造叢集的解決方案
 
快速上手 Windows Containers 容器技術 (Docker Taipei)
快速上手 Windows Containers 容器技術 (Docker Taipei)快速上手 Windows Containers 容器技術 (Docker Taipei)
快速上手 Windows Containers 容器技術 (Docker Taipei)
 
Continuous Delivery - 敏捷開發的最後一哩路
Continuous Delivery - 敏捷開發的最後一哩路Continuous Delivery - 敏捷開發的最後一哩路
Continuous Delivery - 敏捷開發的最後一哩路
 
Yet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom upYet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom up
 
用 Drone 打造 輕量級容器持續交付平台
用 Drone 打造輕量級容器持續交付平台用 Drone 打造輕量級容器持續交付平台
用 Drone 打造 輕量級容器持續交付平台
 
Docker home ted
Docker home tedDocker home ted
Docker home ted
 
Wot2013云计算架构师峰会 -陈轶飞2
Wot2013云计算架构师峰会 -陈轶飞2Wot2013云计算架构师峰会 -陈轶飞2
Wot2013云计算架构师峰会 -陈轶飞2
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率
 
Docker 淺入淺出
Docker 淺入淺出Docker 淺入淺出
Docker 淺入淺出
 
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學
 

Andere mochten auch

Native iphone app test automation with appium
Native iphone app test automation with appiumNative iphone app test automation with appium
Native iphone app test automation with appium
James Eisenhauer
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)
Dennys Hsieh
 

Andere mochten auch (20)

Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineDelivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Pipeline: Continuous Delivery as Code in Jenkins 2.0
Pipeline: Continuous Delivery as Code in Jenkins 2.0Pipeline: Continuous Delivery as Code in Jenkins 2.0
Pipeline: Continuous Delivery as Code in Jenkins 2.0
 
SD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-Code
SD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-CodeSD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-Code
SD DevOps Meet-up - Jenkins 2.0 and Pipeline-as-Code
 
Native iphone app test automation with appium
Native iphone app test automation with appiumNative iphone app test automation with appium
Native iphone app test automation with appium
 
Scaling your Jenkins CI pipeline
Scaling your Jenkins CI pipelineScaling your Jenkins CI pipeline
Scaling your Jenkins CI pipeline
 
Jenkins Pipeline - Seville JAM
Jenkins Pipeline - Seville JAMJenkins Pipeline - Seville JAM
Jenkins Pipeline - Seville JAM
 
Jenkins Plugin Development With Gradle And Groovy
Jenkins Plugin Development With Gradle And GroovyJenkins Plugin Development With Gradle And Groovy
Jenkins Plugin Development With Gradle And Groovy
 
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
 
Jenkins Best Practices
Jenkins Best PracticesJenkins Best Practices
Jenkins Best Practices
 
Building Jenkins Pipelines at Scale
Building Jenkins Pipelines at ScaleBuilding Jenkins Pipelines at Scale
Building Jenkins Pipelines at Scale
 
Continuous Development Pipeline
Continuous Development PipelineContinuous Development Pipeline
Continuous Development Pipeline
 
Continuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and JenkinsContinuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and Jenkins
 
Jenkins days workshop pipelines - Eric Long
Jenkins days workshop  pipelines - Eric LongJenkins days workshop  pipelines - Eric Long
Jenkins days workshop pipelines - Eric Long
 
從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理
 
MOPCON 2015 - 軟體、測試、程式設計家
MOPCON 2015 - 軟體、測試、程式設計家MOPCON 2015 - 軟體、測試、程式設計家
MOPCON 2015 - 軟體、測試、程式設計家
 
用十分鐘 學會《資料結構、演算法和計算理論》
用十分鐘  學會《資料結構、演算法和計算理論》用十分鐘  學會《資料結構、演算法和計算理論》
用十分鐘 學會《資料結構、演算法和計算理論》
 
手機自動化測試和持續整合
手機自動化測試和持續整合手機自動化測試和持續整合
手機自動化測試和持續整合
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)
 
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
 

Ähnlich wie JCConf2016 Jenkins Pipeline

A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
Wen-Tien Chang
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
LearningTech
 
快!快!快! 互联网第一条军规
快!快!快! 互联网第一条军规快!快!快! 互联网第一条军规
快!快!快! 互联网第一条军规
yangdj
 
广告技术部自动化测试介绍.pdf
广告技术部自动化测试介绍.pdf广告技术部自动化测试介绍.pdf
广告技术部自动化测试介绍.pdf
bj_qa
 
02.python.开发最佳实践
02.python.开发最佳实践02.python.开发最佳实践
02.python.开发最佳实践
Na Lee
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
netdbncku
 

Ähnlich wie JCConf2016 Jenkins Pipeline (20)

Angular 4 網站開發最佳實務 (Modern Web 2017)
Angular 4 網站開發最佳實務 (Modern Web 2017)Angular 4 網站開發最佳實務 (Modern Web 2017)
Angular 4 網站開發最佳實務 (Modern Web 2017)
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
 
該怎麼樣(認真的)部署你的 Python Web 應用程式?
該怎麼樣(認真的)部署你的 Python Web 應用程式?該怎麼樣(認真的)部署你的 Python Web 應用程式?
該怎麼樣(認真的)部署你的 Python Web 應用程式?
 
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
快!快!快! 互联网第一条军规
快!快!快! 互联网第一条军规快!快!快! 互联网第一条军规
快!快!快! 互联网第一条军规
 
NCURSES Programming HOWTO
NCURSES Programming HOWTONCURSES Programming HOWTO
NCURSES Programming HOWTO
 
Jenkins introduction
Jenkins introductionJenkins introduction
Jenkins introduction
 
Phalcon2014 Startup
Phalcon2014 StartupPhalcon2014 Startup
Phalcon2014 Startup
 
Continuous Delivery Workshop with Ansible x GitLab CI (3rd)
Continuous Delivery Workshop with Ansible x GitLab CI (3rd)Continuous Delivery Workshop with Ansible x GitLab CI (3rd)
Continuous Delivery Workshop with Ansible x GitLab CI (3rd)
 
使用 eBPF 代替 iptables 加速服务网格-刘齐均Kebe.pdf
使用 eBPF 代替 iptables 加速服务网格-刘齐均Kebe.pdf使用 eBPF 代替 iptables 加速服务网格-刘齐均Kebe.pdf
使用 eBPF 代替 iptables 加速服务网格-刘齐均Kebe.pdf
 
ASP.NET MVC 6 新功能探索
ASP.NET MVC 6 新功能探索ASP.NET MVC 6 新功能探索
ASP.NET MVC 6 新功能探索
 
千呼萬喚始出來的 Java SE 7
千呼萬喚始出來的 Java SE 7千呼萬喚始出來的 Java SE 7
千呼萬喚始出來的 Java SE 7
 
广告技术部自动化测试介绍.pdf
广告技术部自动化测试介绍.pdf广告技术部自动化测试介绍.pdf
广告技术部自动化测试介绍.pdf
 
02.python.开发最佳实践
02.python.开发最佳实践02.python.开发最佳实践
02.python.开发最佳实践
 
Ceph customize ap is for programmatic access with python
Ceph customize ap is for programmatic access with pythonCeph customize ap is for programmatic access with python
Ceph customize ap is for programmatic access with python
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
 
Angular 5 全新功能探索 @ JSDC2017
Angular 5 全新功能探索 @ JSDC2017Angular 5 全新功能探索 @ JSDC2017
Angular 5 全新功能探索 @ JSDC2017
 
前端自動化工具
前端自動化工具前端自動化工具
前端自動化工具
 
Bitbucket pipeline CI
Bitbucket pipeline CIBitbucket pipeline CI
Bitbucket pipeline CI
 

Mehr von Ching Yi Chan (12)

JCConf2015: groovy to gradle
 JCConf2015: groovy to gradle JCConf2015: groovy to gradle
JCConf2015: groovy to gradle
 
Linking error
Linking errorLinking error
Linking error
 
老舊web上雲端
老舊web上雲端老舊web上雲端
老舊web上雲端
 
Java Build Tool course in 2011
Java Build Tool course in 2011Java Build Tool course in 2011
Java Build Tool course in 2011
 
using Queue Server for batch processing
using Queue Server for batch processingusing Queue Server for batch processing
using Queue Server for batch processing
 
idea: talk about the Active Cache
idea: talk about the Active Cacheidea: talk about the Active Cache
idea: talk about the Active Cache
 
Talk about fabric
Talk about fabricTalk about fabric
Talk about fabric
 
Java web programming
Java web programmingJava web programming
Java web programming
 
Android NDK (JUG@TW 2011, Oct.)
Android NDK (JUG@TW 2011, Oct.)Android NDK (JUG@TW 2011, Oct.)
Android NDK (JUG@TW 2011, Oct.)
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
OSGi Small Lab
OSGi Small LabOSGi Small Lab
OSGi Small Lab
 
Osgi Intro
Osgi IntroOsgi Intro
Osgi Intro
 

JCConf2016 Jenkins Pipeline

  • 2. 什麼是 Pipeline • Delivery Pipeline (from Continuous Delivery) • Jenkins Workflow Plugins • Job Workflow Pipeline • Pipeline 由多個 Step 組成,並且⽀支援 Pause/Resume • Pipeline 內的狀態必需可序列化 (Serializable) • 或宣告為不必列⼊入狀態 @NonCPS 的 function
  • 3. 為什麼是 Pipeline • 依然是 Jenkins Job 的⼀一種,依然很 FreeStyle。 • 為的是 Pipeline as Code • 它是 groovy DSL (domain specific language) 版本控制 比 FreeStyle 更 FreeStyle
  • 4. Pipeline DSL • Jenkins 的 Pipeline 介紹
 https://jenkins.io/solutions/pipeline/ • Pipeline 寫作教學
 https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md • Pipeline 設計說明
 https://github.com/jenkinsci/workflow-cps-plugin/blob/master/README.md • Pipeline Steps Reference
 https://jenkins.io/doc/pipeline/steps/ • Pipeline 最佳實踐
 https://www.cloudbees.com/blog/top-10-best-practices-jenkins-pipeline-plugin 主要看這個 遇到問題查這個
  • 5. 建⽴立 Pipeline Job • Pipeline Script from in-place editor • Pipeline Script from SCM • Multi-branch Pipeline (from SCM) 推薦使用 SCM 的方式 適合單 1 專案,不同階段的 Pipeline 自動建立 僅推薦應用於證驗 Script 語法
  • 6. 建⽴立 Pipeline 的⽅方式 • Pipeline Script Editor
  • 7. 建⽴立 Pipeline 的⽅方式 • Pipeline Script from SCM
  • 8. Pipeline 規劃 SCM Checkout WarBuild Test SCM Commit DeployRelease
  • 10. Steps: node, stage, echo node { stage ('checkout') { echo 'checkout from git' } stage ('build') { echo 'build' } // … skip … } 在哪一台機器跑 哪一個階段 做些什麼
  • 11. Steps: git stage ('checkout') { echo 'checkout from git' git url: 'https://my-scm/path/my-project.git' branch: 'master' } optional
  • 12. Steps: dir, pwd, sh (bat) dir ('project') { pwd() stage ('build') { sh """gradle clean build""" } stage ('test') { sh """gradle check""" } // … skip … }
  • 13. Steps: step, archiveArtifacts stage ('archive') { step([$class: 'ArtifactArchiver', 
 artifacts: "build/**/*.war", 
 fingerprint: true]) } stage ('archive') { archiveArtifacts 
 artifacts: "build/**/*.war", 
 fingerprint: true } 舊的寫法 新的寫法 requires Jenkins 2.2+ with newer plugins
  • 14. Refactoring Pipeline • 使⽤用 Function 合併多個 steps 為⼀一個有意義的動作 • 實作新的 Pipeline Step • 使⽤用 Pipeline Shared Libraries 你瘋了嗎? 無法跨 Pipeline Script 使用 只能推惹! https://github.com/jenkinsci/workflow-cps-global-lib-plugin https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Shared+Groovy+Libraries+Plugin
  • 15. Pipeline Shared Library • 使⽤用⽅方法 • 啟⽤用 Jenkins ssh (因為 Jenkins 內建的 git repo ⺫⽬目前僅能 ssh auth) • 安裝 Plugin (id: workflow-cps-global-lib) • 使⽤用 git 指令 commit & push 提交 Shared Library 並在 Pipeline Script 開始使⽤用 https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+SSH web console 搜尋 plugin 找不到,用 cli 直接按裝吧!
  • 16. Pipeline 使⽤用⼼心得 • Pipeline as Code 可以⽅方便版本管理 • 內建的 Pipeline Step 不夠多,得常得依賴 sh 或 bat 呼叫外部指令。 • 間接使⽤用 DevOps Tool 處理 • Ansible, Chef, Puppet • Ant, Maven, Gradle
  • 17. Q & A