SlideShare a Scribd company logo
1 of 41
0Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Jenkins Deployment Pipelines
» Introduction
» Jenkins
» Pipelines
» Hands on
» Improvements
» Downsides
1Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Introduction
2Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Me, myself and I
» Nicole Cordes
» working at CPS-IT GmbH in Berlin
» TYPO3 community member since 2011
» Core and Security Team member
» contributed some Symfony improvements for Windows in Finder
» some libraries and own projects based on Symfony
» Twitter: @IchHabRecht
» GitHub: https://github.com/IchHabRecht
3Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
About this talk
» who or what is Jenkins
» understanding pipelines
» my way of pipeline integration into Jenkins
» useful Jenkins plugins to be more productive
» drawbacks of the solution
4Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Jenkins
5Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Jenkins
» automation (continuous integration) server
» open source project
» written in Java
» previously known as Hudson
» 2011 Oracle bought Sun and wanted to develop a commercial version
» the development was renamed to Jenkins and continued by the Hudson inventors
6Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Jenkins
» easy to install / maintain
» able to run any kind of customized task
» you can define multiple triggers
» expansible by a huge amount of different plugins
» distribute work across multiple machines
7Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Pipelines
8Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Pipelines
» pipeline means multiple stages with different tasks to do
» build stage
» test stage
» deploy stage
» tool stage
9Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Job pool
tool
SonarQube
phpDocumentor
test
PHPUnit
JUnit
Behat
Codeception
PHP Lint
build
composer
Node.js
asset management
deploy
rsync (any tool)
clear cache
warmup cache
database migrations
10Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Understanding workspaces
» build and test stage share a workspace
» build stage ensures a proper state of your project
» test stage runs tests and ensures stability
» deployment has its own workspace
» you don’t want to deploy all dev tools
» tool stage usually uses deployment workspace as well but can have its own one
11Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Build your project
test
PHPUnit
PHP Lint
build
composer
deploy
rsync (any tool)
» Project A (simple project)
test
PHPUnit
PHP Lint
» Project B (advanced project)
build
composer
Node.js
deploy
Deployer
clear cache
tool
SonarQube
phpDocumentor
12Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Job pool
» each task is an own Jenkins job
» you can easily set up new projects from the job pool
» you can add new jobs to the job pool
» you can change one job and it is changed in every project
13Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Hands on
(Project A)
14Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Installing Plugins
» three required plugins to support minimal pipelines
» Git plugin
» Environment Injector Plugin
» Parameterized Trigger plugin
» Copy Artifact Plugin
15Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Create the first job
» enter template name
» choose to build a “Freestyle project”
» allow template jobs to use artifacts
» choose “Prepare an environment for the run”
» enter some project server configuration
» those properties will be available as ENV vars
16Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Create the first job
» define your “Source Code Management”
» choose “Git” and enter your information
» enable “Poll SCM” trigger without any schedule
» this allows you to call
http://jenkins/git/notifyCommit?url=https://github.com/IchHabRecht/some-project.git
to trigger your build from any other resource
17Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Create the first job
» add a build step “Execute shell”
» create a tar file of the Git checkout
» add a post-build action “Archive the artifacts”
» enter your tar file name
» activate “Fingerprint all archived artifacts“
18Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Create the template jobs
» create a new job “template-build-simple-project” as Freestyle project
» activate “Advanced Project Options“
» use a custom workspace
“${ROOT_JOB_NAME}_build/workspace“
» add a build step “Copy artifacts from another project”
» use project name “${ROOT_JOB_NAME}”
» use specific build “${ROOT_BUILD_NUMBER}”
19Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Create the template jobs
» add a build step “Execute shell”
» untar the artifact and delete it
» now our build workspace is prepared to run single tasks
20Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Create the template tasks
» create a new job “template-build-composer-install” as Freestyle project
» use custom workspace “${TEMPLATE_BUILD_WORKSPACE}”
» add a build step “Execute shell” with command `composer install`
» create a new job “template-test-phpunit” as Freestyle project
» use custom workspace “${TEMPLATE_BUILD_WORKSPACE}”
» add a build step “Execute shell” with command `bin/phpunit`
» depending on your framework you might need more configuration here
21Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Create the template tasks
» create a new job “template-test-php-lint” as Freestyle project
» use custom workspace “${TEMPLATE_BUILD_WORKSPACE}”
» add a build step “Execute shell” with command
for file in $(find “${WORKSPACE}/” -name *.php); do
php -d display_errors=stderr -l “$file” > /dev/null
done
» create a new job “template-deploy-rsync” as Freestyle project
» use custom workspace “${TEMPLATE_DEPLOY_WORKSPACE}”
» add a build step “Execute shell” with some rsync function
rsync -rvzle ssh -E --delete “${WORKSPACE}/”
“user@${SERVER}:${WEB_ROOT}/”
22Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Create project type templates
» create a new job “template-test-simple-project” as Freestyle project
» no specific settings needed so far as tests using the build workspace
» create a new job “template-deploy-simple-project” as Freestyle project
» activate “Advanced Project Options“
» use a custom workspace
“${ROOT_JOB_NAME}_deploy/workspace“
» add a build step “Copy artifacts from another project”
» use project name “${ROOT_JOB_NAME}”
» use specific build “${ROOT_BUILD_NUMBER}”
» add a build step “Execute shell” and untar the artifact and delete it
23Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Template view
24Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Connecting the deploy jobs
» re-configure “template-deploy-simple-project”
» add a new build step “Trigger/call builds on other projects”
» projects to build “template-deploy-rsync”
» enable “Block until the triggered projects finish their builds”
» add parameters “Current build parameters”
» add parameters “Predefined parameters”
TEMPLATE_DEPLOY_WORKSPACE=${WORKSPACE}
25Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Connecting the deploy jobs
26Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Connecting the test jobs
» re-configure “template-test-simple-project”
» add a new build step “Trigger/call builds on other projects”
» projects to build “template-test-phpunit,template-test-php-lint”
» enable “Block until the triggered projects finish their builds”
» add parameters “Current build parameters”
27Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Connecting the build jobs
» re-configure “template-build-simple-project”
» add a new build step “Trigger/call builds on other projects”
» make sure it is the last step in this job
» projects to build “template-build-composer-install”
» enable “Block until the triggered projects finish their builds”
» add parameters “Current build parameters”
» add parameters “Predefined parameters”
TEMPLATE_BUILD_WORKSPACE=${WORKSPACE}
28Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Connecting the build jobs
» add another new build step “Trigger/call builds on other projects”
» make sure it is the last step in this job
» projects to build “template-test-simple-project”
» enable “Block until the triggered projects finish their builds”
» add parameters “Current build parameters”
» add parameters “Predefined parameters”
TEMPLATE_BUILD_WORKSPACE=${WORKSPACE}
» add a post-build action “Trigger parameterized build on other projects”
» projects to build “template-deploy-simple-project”
» enable “Block until the triggered projects finish their builds”
» add parameters “Current build parameters”
29Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Adding the pipeline to Project A
» re-configure “Project A”
» add a post-build action “Trigger parameterized build on other projects”
» make sure it is the last step in this job
» projects to build “template-build-simple-project”
» enable “Block until the triggered projects finish their builds”
» add parameters “Current build parameters”
» add parameters “Predefined parameters”
ROOT_JOB_NAME=${JOB_NAME}
ROOT_BUILD_NUMBER=${BUILD_NUMBER}
30Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Conclusions
» you can now build Project A which will trigger all other jobs
» currently only the checkout is deployed; you maybe have to add a
“template-deploy-composer-install” job running `composer install –no-dev`
» you can add a new “Project C” as another simple project
» create a new job and enter a name
» Mark “Copy existing Item” and choose “Project A”
» you just need to change the server variables and the git repository
» you are able to extend your job pool and define other project templates
31Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Improvements
32Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
SCM Sync Configuration Plugin
» store your Jenkins configuration in a Git repository
» comment your changes
» bulk edit jobs
33Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Green Balls
» turn the blue status icons into green ones
34Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Role-based Authorization Strategy
» manage and assign roles to users
» global roles like “Administrator” “Developer” “Guest”
» project roles based on project template names
» use client names as project prefixes
35Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Workspace Cleanup Plugin
» delete the workspace before a new build is started
» useful for the “umbrella” template jobs
36Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Email Extension Plugin
» versatile email notification plugin
» send emails to all commiters
» send emails to project members
» attach build logs
37Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Further template improvements
» variable PHP version per project
» Node.js caching
» multiple server support for deployment
» multiple server types according to Git Flow branching model
38Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Downsides
39Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Missing features
» due to the post-build actions the root job never fails
» job pool tasks don’t save state per root template nor Git branch
40Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines
Thank you
for your attention!

More Related Content

What's hot

Functional tests with TYPO3
Functional tests with TYPO3Functional tests with TYPO3
Functional tests with TYPO3cpsitgmbh
 
iOS Behavior-Driven Development
iOS Behavior-Driven DevelopmentiOS Behavior-Driven Development
iOS Behavior-Driven DevelopmentBrian Gesiak
 
An introduction to Ansible
An introduction to AnsibleAn introduction to Ansible
An introduction to AnsibleJulien Pivotto
 
Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Daniele Pallastrelli
 
ReactJS for Programmers
ReactJS for ProgrammersReactJS for Programmers
ReactJS for ProgrammersDavid Rodenas
 
RSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversRSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversBrian Gesiak
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Andres Almiray
 
Functional Reactive Programming on Android
Functional Reactive Programming on AndroidFunctional Reactive Programming on Android
Functional Reactive Programming on AndroidSam Lee
 
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers VersionCool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers VersionSchalk Cronjé
 
Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0Binary Studio
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpAll Things Open
 
Spock Testing Framework - The Next Generation
Spock Testing Framework - The Next GenerationSpock Testing Framework - The Next Generation
Spock Testing Framework - The Next GenerationBTI360
 
The journey of asyncio adoption in instagram
The journey of asyncio adoption in instagramThe journey of asyncio adoption in instagram
The journey of asyncio adoption in instagramJimmy Lai
 
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkContract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkRed Hat Developers
 

What's hot (20)

Functional tests with TYPO3
Functional tests with TYPO3Functional tests with TYPO3
Functional tests with TYPO3
 
Celery
CeleryCelery
Celery
 
iOS Behavior-Driven Development
iOS Behavior-Driven DevelopmentiOS Behavior-Driven Development
iOS Behavior-Driven Development
 
An introduction to Ansible
An introduction to AnsibleAn introduction to Ansible
An introduction to Ansible
 
Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++
 
ReactJS for Programmers
ReactJS for ProgrammersReactJS for Programmers
ReactJS for Programmers
 
RSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversRSpec 3.0: Under the Covers
RSpec 3.0: Under the Covers
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
 
OHHttpStubs
OHHttpStubsOHHttpStubs
OHHttpStubs
 
Functional Reactive Programming on Android
Functional Reactive Programming on AndroidFunctional Reactive Programming on Android
Functional Reactive Programming on Android
 
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers VersionCool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
 
Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0
 
Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
 
JS and patterns
JS and patternsJS and patterns
JS and patterns
 
Spock Testing Framework - The Next Generation
Spock Testing Framework - The Next GenerationSpock Testing Framework - The Next Generation
Spock Testing Framework - The Next Generation
 
Spock Framework
Spock FrameworkSpock Framework
Spock Framework
 
The journey of asyncio adoption in instagram
The journey of asyncio adoption in instagramThe journey of asyncio adoption in instagram
The journey of asyncio adoption in instagram
 
Celery with python
Celery with pythonCelery with python
Celery with python
 
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkContract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
 

Viewers also liked

Fluid Security
Fluid SecurityFluid Security
Fluid Securitycpsitgmbh
 
TYPO3 Caching
TYPO3 CachingTYPO3 Caching
TYPO3 Cachingcpsitgmbh
 
TYPO3 Contribution Bootup Day
TYPO3 Contribution Bootup DayTYPO3 Contribution Bootup Day
TYPO3 Contribution Bootup Daycpsitgmbh
 
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Max Romanovsky
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Alexander Lisachenko
 

Viewers also liked (6)

Fluid Security
Fluid SecurityFluid Security
Fluid Security
 
Hooks
HooksHooks
Hooks
 
TYPO3 Caching
TYPO3 CachingTYPO3 Caching
TYPO3 Caching
 
TYPO3 Contribution Bootup Day
TYPO3 Contribution Bootup DayTYPO3 Contribution Bootup Day
TYPO3 Contribution Bootup Day
 
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
 

Similar to Jenkins Deployment Pipelines with Templates

OpenShift Build Pipelines @ Lightweight Java User Group Meetup
OpenShift Build Pipelines @ Lightweight Java User Group MeetupOpenShift Build Pipelines @ Lightweight Java User Group Meetup
OpenShift Build Pipelines @ Lightweight Java User Group MeetupTobias Schneck
 
Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015Kurt Madel
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins PipelinesSteffen Gebert
 
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgartOpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgartTobias Schneck
 
Configuration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL PluginConfiguration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL PluginDaniel Spilker
 
Mihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate EverythingMihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate EverythingMihai Criveti
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014Rafe Colton
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...Docker, Inc.
 
Docker Container As A Service - JAX 2016
Docker Container As A Service - JAX 2016Docker Container As A Service - JAX 2016
Docker Container As A Service - JAX 2016Patrick Chanezon
 
Continuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL ServerContinuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL ServerChris Adkin
 
Leiningen2 - humane build management for clojure
Leiningen2 - humane build management for clojureLeiningen2 - humane build management for clojure
Leiningen2 - humane build management for clojureJohn Stevenson
 
Eclipse DemoCamp Munich - Docker Tooling and Vagrant Tooling
Eclipse DemoCamp Munich  - Docker Tooling and Vagrant ToolingEclipse DemoCamp Munich  - Docker Tooling and Vagrant Tooling
Eclipse DemoCamp Munich - Docker Tooling and Vagrant ToolingXavier Coulon
 
Host any project in che with stacks & chefiles
Host any project in che with stacks & chefilesHost any project in che with stacks & chefiles
Host any project in che with stacks & chefilesFlorent BENOIT
 
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los AngelesJenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los AngelesAndy Pemberton
 
Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript Serge van den Oever
 

Similar to Jenkins Deployment Pipelines with Templates (20)

OpenShift Build Pipelines @ Lightweight Java User Group Meetup
OpenShift Build Pipelines @ Lightweight Java User Group MeetupOpenShift Build Pipelines @ Lightweight Java User Group Meetup
OpenShift Build Pipelines @ Lightweight Java User Group Meetup
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgartOpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
OpenShift-Build-Pipelines: Build -> Test -> Run! @JavaForumStuttgart
 
Configuration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL PluginConfiguration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL Plugin
 
Mihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate EverythingMihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate Everything
 
Job DSL Plugin for Jenkins
Job DSL Plugin for JenkinsJob DSL Plugin for Jenkins
Job DSL Plugin for Jenkins
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
 
0507 057 01 98 * Adana Klima Tamir Servisi
0507 057 01 98 * Adana Klima Tamir Servisi0507 057 01 98 * Adana Klima Tamir Servisi
0507 057 01 98 * Adana Klima Tamir Servisi
 
Docker Container As A Service - JAX 2016
Docker Container As A Service - JAX 2016Docker Container As A Service - JAX 2016
Docker Container As A Service - JAX 2016
 
Continuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL ServerContinuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL Server
 
Leiningen2 - humane build management for clojure
Leiningen2 - humane build management for clojureLeiningen2 - humane build management for clojure
Leiningen2 - humane build management for clojure
 
CI and CD
CI and CDCI and CD
CI and CD
 
AWS Code Services
AWS Code ServicesAWS Code Services
AWS Code Services
 
Eclipse DemoCamp Munich - Docker Tooling and Vagrant Tooling
Eclipse DemoCamp Munich  - Docker Tooling and Vagrant ToolingEclipse DemoCamp Munich  - Docker Tooling and Vagrant Tooling
Eclipse DemoCamp Munich - Docker Tooling and Vagrant Tooling
 
Host any project in che with stacks & chefiles
Host any project in che with stacks & chefilesHost any project in che with stacks & chefiles
Host any project in che with stacks & chefiles
 
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los AngelesJenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
 
Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript
 

Recently uploaded

『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesLumiverse Solutions Pvt Ltd
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 

Recently uploaded (9)

『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best Practices
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 

Jenkins Deployment Pipelines with Templates

  • 1. 0Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Jenkins Deployment Pipelines » Introduction » Jenkins » Pipelines » Hands on » Improvements » Downsides
  • 2. 1Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Introduction
  • 3. 2Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Me, myself and I » Nicole Cordes » working at CPS-IT GmbH in Berlin » TYPO3 community member since 2011 » Core and Security Team member » contributed some Symfony improvements for Windows in Finder » some libraries and own projects based on Symfony » Twitter: @IchHabRecht » GitHub: https://github.com/IchHabRecht
  • 4. 3Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines About this talk » who or what is Jenkins » understanding pipelines » my way of pipeline integration into Jenkins » useful Jenkins plugins to be more productive » drawbacks of the solution
  • 5. 4Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Jenkins
  • 6. 5Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Jenkins » automation (continuous integration) server » open source project » written in Java » previously known as Hudson » 2011 Oracle bought Sun and wanted to develop a commercial version » the development was renamed to Jenkins and continued by the Hudson inventors
  • 7. 6Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Jenkins » easy to install / maintain » able to run any kind of customized task » you can define multiple triggers » expansible by a huge amount of different plugins » distribute work across multiple machines
  • 8. 7Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Pipelines
  • 9. 8Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Pipelines » pipeline means multiple stages with different tasks to do » build stage » test stage » deploy stage » tool stage
  • 10. 9Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Job pool tool SonarQube phpDocumentor test PHPUnit JUnit Behat Codeception PHP Lint build composer Node.js asset management deploy rsync (any tool) clear cache warmup cache database migrations
  • 11. 10Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Understanding workspaces » build and test stage share a workspace » build stage ensures a proper state of your project » test stage runs tests and ensures stability » deployment has its own workspace » you don’t want to deploy all dev tools » tool stage usually uses deployment workspace as well but can have its own one
  • 12. 11Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Build your project test PHPUnit PHP Lint build composer deploy rsync (any tool) » Project A (simple project) test PHPUnit PHP Lint » Project B (advanced project) build composer Node.js deploy Deployer clear cache tool SonarQube phpDocumentor
  • 13. 12Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Job pool » each task is an own Jenkins job » you can easily set up new projects from the job pool » you can add new jobs to the job pool » you can change one job and it is changed in every project
  • 14. 13Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Hands on (Project A)
  • 15. 14Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Installing Plugins » three required plugins to support minimal pipelines » Git plugin » Environment Injector Plugin » Parameterized Trigger plugin » Copy Artifact Plugin
  • 16. 15Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Create the first job » enter template name » choose to build a “Freestyle project” » allow template jobs to use artifacts » choose “Prepare an environment for the run” » enter some project server configuration » those properties will be available as ENV vars
  • 17. 16Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Create the first job » define your “Source Code Management” » choose “Git” and enter your information » enable “Poll SCM” trigger without any schedule » this allows you to call http://jenkins/git/notifyCommit?url=https://github.com/IchHabRecht/some-project.git to trigger your build from any other resource
  • 18. 17Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Create the first job » add a build step “Execute shell” » create a tar file of the Git checkout » add a post-build action “Archive the artifacts” » enter your tar file name » activate “Fingerprint all archived artifacts“
  • 19. 18Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Create the template jobs » create a new job “template-build-simple-project” as Freestyle project » activate “Advanced Project Options“ » use a custom workspace “${ROOT_JOB_NAME}_build/workspace“ » add a build step “Copy artifacts from another project” » use project name “${ROOT_JOB_NAME}” » use specific build “${ROOT_BUILD_NUMBER}”
  • 20. 19Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Create the template jobs » add a build step “Execute shell” » untar the artifact and delete it » now our build workspace is prepared to run single tasks
  • 21. 20Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Create the template tasks » create a new job “template-build-composer-install” as Freestyle project » use custom workspace “${TEMPLATE_BUILD_WORKSPACE}” » add a build step “Execute shell” with command `composer install` » create a new job “template-test-phpunit” as Freestyle project » use custom workspace “${TEMPLATE_BUILD_WORKSPACE}” » add a build step “Execute shell” with command `bin/phpunit` » depending on your framework you might need more configuration here
  • 22. 21Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Create the template tasks » create a new job “template-test-php-lint” as Freestyle project » use custom workspace “${TEMPLATE_BUILD_WORKSPACE}” » add a build step “Execute shell” with command for file in $(find “${WORKSPACE}/” -name *.php); do php -d display_errors=stderr -l “$file” > /dev/null done » create a new job “template-deploy-rsync” as Freestyle project » use custom workspace “${TEMPLATE_DEPLOY_WORKSPACE}” » add a build step “Execute shell” with some rsync function rsync -rvzle ssh -E --delete “${WORKSPACE}/” “user@${SERVER}:${WEB_ROOT}/”
  • 23. 22Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Create project type templates » create a new job “template-test-simple-project” as Freestyle project » no specific settings needed so far as tests using the build workspace » create a new job “template-deploy-simple-project” as Freestyle project » activate “Advanced Project Options“ » use a custom workspace “${ROOT_JOB_NAME}_deploy/workspace“ » add a build step “Copy artifacts from another project” » use project name “${ROOT_JOB_NAME}” » use specific build “${ROOT_BUILD_NUMBER}” » add a build step “Execute shell” and untar the artifact and delete it
  • 24. 23Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Template view
  • 25. 24Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Connecting the deploy jobs » re-configure “template-deploy-simple-project” » add a new build step “Trigger/call builds on other projects” » projects to build “template-deploy-rsync” » enable “Block until the triggered projects finish their builds” » add parameters “Current build parameters” » add parameters “Predefined parameters” TEMPLATE_DEPLOY_WORKSPACE=${WORKSPACE}
  • 26. 25Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Connecting the deploy jobs
  • 27. 26Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Connecting the test jobs » re-configure “template-test-simple-project” » add a new build step “Trigger/call builds on other projects” » projects to build “template-test-phpunit,template-test-php-lint” » enable “Block until the triggered projects finish their builds” » add parameters “Current build parameters”
  • 28. 27Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Connecting the build jobs » re-configure “template-build-simple-project” » add a new build step “Trigger/call builds on other projects” » make sure it is the last step in this job » projects to build “template-build-composer-install” » enable “Block until the triggered projects finish their builds” » add parameters “Current build parameters” » add parameters “Predefined parameters” TEMPLATE_BUILD_WORKSPACE=${WORKSPACE}
  • 29. 28Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Connecting the build jobs » add another new build step “Trigger/call builds on other projects” » make sure it is the last step in this job » projects to build “template-test-simple-project” » enable “Block until the triggered projects finish their builds” » add parameters “Current build parameters” » add parameters “Predefined parameters” TEMPLATE_BUILD_WORKSPACE=${WORKSPACE} » add a post-build action “Trigger parameterized build on other projects” » projects to build “template-deploy-simple-project” » enable “Block until the triggered projects finish their builds” » add parameters “Current build parameters”
  • 30. 29Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Adding the pipeline to Project A » re-configure “Project A” » add a post-build action “Trigger parameterized build on other projects” » make sure it is the last step in this job » projects to build “template-build-simple-project” » enable “Block until the triggered projects finish their builds” » add parameters “Current build parameters” » add parameters “Predefined parameters” ROOT_JOB_NAME=${JOB_NAME} ROOT_BUILD_NUMBER=${BUILD_NUMBER}
  • 31. 30Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Conclusions » you can now build Project A which will trigger all other jobs » currently only the checkout is deployed; you maybe have to add a “template-deploy-composer-install” job running `composer install –no-dev` » you can add a new “Project C” as another simple project » create a new job and enter a name » Mark “Copy existing Item” and choose “Project A” » you just need to change the server variables and the git repository » you are able to extend your job pool and define other project templates
  • 32. 31Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Improvements
  • 33. 32Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines SCM Sync Configuration Plugin » store your Jenkins configuration in a Git repository » comment your changes » bulk edit jobs
  • 34. 33Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Green Balls » turn the blue status icons into green ones
  • 35. 34Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Role-based Authorization Strategy » manage and assign roles to users » global roles like “Administrator” “Developer” “Guest” » project roles based on project template names » use client names as project prefixes
  • 36. 35Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Workspace Cleanup Plugin » delete the workspace before a new build is started » useful for the “umbrella” template jobs
  • 37. 36Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Email Extension Plugin » versatile email notification plugin » send emails to all commiters » send emails to project members » attach build logs
  • 38. 37Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Further template improvements » variable PHP version per project » Node.js caching » multiple server support for deployment » multiple server types according to Git Flow branching model
  • 39. 38Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Downsides
  • 40. 39Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Missing features » due to the post-build actions the root job never fails » job pool tasks don’t save state per root template nor Git branch
  • 41. 40Nicole Cordes, SymfonyCon Berlin 2016, Jenkins Deployment Pipelines Thank you for your attention!