SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
Jenkins
automation
Using Python to automate Jenkins
About me
● Work with builds for 8 years
● Was Java architect and developer for 7
years before that
● Originally from Russia, but lived and work in
US, UK, Denmark and now in Singapore
● Follow me on Github: @lechat
Questions
● How many jobs your Jenkins has?
● Do you run parallel build pipelines?
● Do you automate Jenkins?
Agenda
● Save Jenkins jobs in a safe place
● Making config.xml easier to handle
● Making branch builds
● Making and running build pipelines
I want to save my (Jenkins) job!
Jenkins backup
● Jobs
of course, they only exist in Jenkins and handcrafted to perfection
● Builds
a history of (not so) useful information
● Keys
usually forgotten essential bit of information
I want to save my (Jenkins) job!
Jenkins backup
● Jobs
Trivial approach - make shell script that will put files somewhere else
Another trivial approach - use Jenkins job to save Jenkins as build artefact
● Useful only as a disaster recovery
Restoring just one job requires Jenkins restart
(only in latest version there is an option to reload job definition)
I want to save my (Jenkins) job!
But why not keep job definition with your source code?
Use jenkinsapi library to save/restore jobs!
What jenkinsapi can do?
● Query Jenkins about jobs, builds, views, nodes
● Create/update jobs, views, nodes (only JNLP nodes for
now)
● Execute jobs
I want to save my (Jenkins) job!
Example 1:
Making easier to handle config.xml
Editing job’s config.xml is not easy
● You need to know plugin/component internal name
● XML is too verbose
● Editing does not scale
Making easier to handle config.xml
Making easier to handle config.xml
Use OpenStack jenkins-job-builder
● Job definition is in YAML
● Good defaults - you only need to specify overrides
● Less stuff to edit
Making easier to handle config.xml
Making easier to handle config.xml
Jenkins-job-builder features
● Create templates for jobs
● Create variables and expand them when job is generated
● Create default values used across multiple jobs
● Define macros for repeated sections
Making branch builds
Example 3: Create jobs for each git branch
Making job pipelines
Making job pipelines is not trivial in Jenkins
Making job pipelines
Making good job pipelines is not trivial in Jenkins
● No visualization when making jobs dependencies
● Have to use “Join” plugin
● Hard to run part of the pipeline
Making job pipelines
Use jenkinsflow library to make and run pipelines
Making job pipelines
Making job pipelines
With jenkinsflow
No dependencies between jobs in Jenkins
You can create dynamic pipelines
You can execute pipelines outside Jenkins
good for building automated Git flows
Summary
All in your source code repository:
● Job definitions
● Job pipelines
● Build automation
No worries about losing Jenkins instance - it can be re-
created in minutes
Reference
jenkinsapi
https://github.com/salimfadhley/jenkinsapi
OpenStack jenkins-job-builder
https://github.com/openstack-infra/jenkins-job-builder
jenkinsflow
https://github.com/lhupfeldt/jenkinsflow
Reference
Job creators + editors (summary)
https://gist.github.com/mika/5237127
XML templates - Hudson job creator
https://github.com/hudson2-plugins/jobcreator-tool
Source code for this presentation
https://github.com/lechat/devops-python-jenkins

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

The Ruby workflow
The Ruby workflowThe Ruby workflow
The Ruby workflow
 
Reusability is the goal
Reusability is the goalReusability is the goal
Reusability is the goal
 
BDD using behat
BDD using behatBDD using behat
BDD using behat
 
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
 
Untangling - fall2017 - week 10
Untangling - fall2017 - week 10Untangling - fall2017 - week 10
Untangling - fall2017 - week 10
 
Untangling11
Untangling11Untangling11
Untangling11
 
Managing changes to eZPublish Database
Managing changes to eZPublish DatabaseManaging changes to eZPublish Database
Managing changes to eZPublish Database
 
Getting started with Angular CLI
Getting started with Angular CLIGetting started with Angular CLI
Getting started with Angular CLI
 
Powerful Automation Made Simple
Powerful Automation Made SimplePowerful Automation Made Simple
Powerful Automation Made Simple
 
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11
 
Getting Started with the Angular 2 CLI
Getting Started with the Angular 2 CLIGetting Started with the Angular 2 CLI
Getting Started with the Angular 2 CLI
 
Engage 2019 Software documentation is fun if you have the right tools: Introd...
Engage 2019 Software documentation is fun if you have the right tools: Introd...Engage 2019 Software documentation is fun if you have the right tools: Introd...
Engage 2019 Software documentation is fun if you have the right tools: Introd...
 
Erlang - Dive Right In
Erlang - Dive Right InErlang - Dive Right In
Erlang - Dive Right In
 
The Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cliThe Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cli
 
Job DSL Plugin for Jenkins
Job DSL Plugin for JenkinsJob DSL Plugin for Jenkins
Job DSL Plugin for Jenkins
 
Untangling spring week5
Untangling spring week5Untangling spring week5
Untangling spring week5
 
Xstrata Kiosk Project Summary
Xstrata Kiosk Project SummaryXstrata Kiosk Project Summary
Xstrata Kiosk Project Summary
 
React vs angular (mobile first battle)
React vs angular (mobile first battle)React vs angular (mobile first battle)
React vs angular (mobile first battle)
 
Let’s be productive with spring boot
Let’s be productive with spring bootLet’s be productive with spring boot
Let’s be productive with spring boot
 

Andere mochten auch

Aprendizaje
AprendizajeAprendizaje
Aprendizaje
omijoch
 
ฉันเหมือนใคร2003
ฉันเหมือนใคร2003ฉันเหมือนใคร2003
ฉันเหมือนใคร2003
018311144
 

Andere mochten auch (20)

Jenkins & Selenium
Jenkins & SeleniumJenkins & Selenium
Jenkins & Selenium
 
Genymotion with Jenkins
Genymotion with JenkinsGenymotion with Jenkins
Genymotion with Jenkins
 
Metrics to guide: agile fluency, continuous delivery and product teams
Metrics to guide: agile fluency, continuous delivery and product teamsMetrics to guide: agile fluency, continuous delivery and product teams
Metrics to guide: agile fluency, continuous delivery and product teams
 
Continous UI testing with Espresso and Jenkins
Continous UI testing with Espresso and JenkinsContinous UI testing with Espresso and Jenkins
Continous UI testing with Espresso and Jenkins
 
Testing with Jenkins, Selenium and Continuous Deployment
Testing with Jenkins, Selenium and Continuous DeploymentTesting with Jenkins, Selenium and Continuous Deployment
Testing with Jenkins, Selenium and Continuous Deployment
 
RightScale Webinar: Continuous Integration and Delivery in the Cloud - How Ri...
RightScale Webinar: Continuous Integration and Delivery in the Cloud - How Ri...RightScale Webinar: Continuous Integration and Delivery in the Cloud - How Ri...
RightScale Webinar: Continuous Integration and Delivery in the Cloud - How Ri...
 
Large scale automation with jenkins
Large scale automation with jenkinsLarge scale automation with jenkins
Large scale automation with jenkins
 
Writing multi-language documentation using Sphinx
Writing multi-language documentation using SphinxWriting multi-language documentation using Sphinx
Writing multi-language documentation using Sphinx
 
Sphinx + robot framework = documentation as result of functional testing
Sphinx + robot framework = documentation as result of functional testingSphinx + robot framework = documentation as result of functional testing
Sphinx + robot framework = documentation as result of functional testing
 
The road to continuous deployment (PHPCon Poland 2016)
The road to continuous deployment (PHPCon Poland 2016)The road to continuous deployment (PHPCon Poland 2016)
The road to continuous deployment (PHPCon Poland 2016)
 
Didactisch atelier 2
Didactisch atelier 2Didactisch atelier 2
Didactisch atelier 2
 
Arkadaslar
ArkadaslarArkadaslar
Arkadaslar
 
Aprendizaje
AprendizajeAprendizaje
Aprendizaje
 
Sweeping Change
Sweeping ChangeSweeping Change
Sweeping Change
 
Keynote - Rapid 2008
Keynote - Rapid 2008Keynote - Rapid 2008
Keynote - Rapid 2008
 
Green computing
Green computingGreen computing
Green computing
 
ฉันเหมือนใคร2003
ฉันเหมือนใคร2003ฉันเหมือนใคร2003
ฉันเหมือนใคร2003
 
Tx2014 Feature and Highlights
Tx2014 Feature and Highlights Tx2014 Feature and Highlights
Tx2014 Feature and Highlights
 
Kranen
KranenKranen
Kranen
 
Saturno
SaturnoSaturno
Saturno
 

Ähnlich wie Jenkins automation

Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021
Joe Ferguson
 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Anton Arhipov
 

Ähnlich wie Jenkins automation (20)

Seven Habits of Highly Effective Jenkins Users (2014 edition!)
Seven Habits of Highly Effective Jenkins Users (2014 edition!)Seven Habits of Highly Effective Jenkins Users (2014 edition!)
Seven Habits of Highly Effective Jenkins Users (2014 edition!)
 
Jenkins 101: Continuos Integration with Jenkins
Jenkins 101: Continuos Integration with JenkinsJenkins 101: Continuos Integration with Jenkins
Jenkins 101: Continuos Integration with Jenkins
 
DevOps: Building by feature with immutable infrastructure at Serv.sg
DevOps: Building by feature with immutable infrastructure at Serv.sgDevOps: Building by feature with immutable infrastructure at Serv.sg
DevOps: Building by feature with immutable infrastructure at Serv.sg
 
DevOps World | Jenkins World 2018 and The Future of Jenkins
DevOps World | Jenkins World 2018 and The Future of JenkinsDevOps World | Jenkins World 2018 and The Future of Jenkins
DevOps World | Jenkins World 2018 and The Future of Jenkins
 
Jenkins in the real world - DevOpsCon 2017
Jenkins in the real world - DevOpsCon 2017Jenkins in the real world - DevOpsCon 2017
Jenkins in the real world - DevOpsCon 2017
 
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared LibraryCodifying the Build and Release Process with a Jenkins Pipeline Shared Library
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
 
Engage 2018 adm04 - The lazy admin wins
Engage 2018   adm04 - The lazy admin winsEngage 2018   adm04 - The lazy admin wins
Engage 2018 adm04 - The lazy admin wins
 
Engage 2018 adm04 The lazy admin wins
Engage 2018   adm04 The lazy admin winsEngage 2018   adm04 The lazy admin wins
Engage 2018 adm04 The lazy admin wins
 
The state of Jenkins pipelines or do I still need freestyle jobs
The state of Jenkins pipelines or do I still need freestyle jobsThe state of Jenkins pipelines or do I still need freestyle jobs
The state of Jenkins pipelines or do I still need freestyle jobs
 
At Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in OperationsAt Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in Operations
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow Tools
 
Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021
 
Grooving with Jenkins
Grooving with JenkinsGrooving with Jenkins
Grooving with Jenkins
 
JenkinsCI
JenkinsCIJenkinsCI
JenkinsCI
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
 
OpenCms Days 2014 Keynote - Step up to OpenCms 9.5
OpenCms Days 2014 Keynote - Step up to OpenCms 9.5OpenCms Days 2014 Keynote - Step up to OpenCms 9.5
OpenCms Days 2014 Keynote - Step up to OpenCms 9.5
 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
 
JUC Europe 2015: Hey! What Did We Just Release?
JUC Europe 2015: Hey! What Did We Just Release?JUC Europe 2015: Hey! What Did We Just Release?
JUC Europe 2015: Hey! What Did We Just Release?
 
Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Jenkinsconf Presentation - Advance jenkins management with multiple projects.Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Jenkinsconf Presentation - Advance jenkins management with multiple projects.
 
Application Development Using Java - DIYComputerScience Course
Application Development Using Java - DIYComputerScience CourseApplication Development Using Java - DIYComputerScience Course
Application Development Using Java - DIYComputerScience Course
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Jenkins automation

  • 2. About me ● Work with builds for 8 years ● Was Java architect and developer for 7 years before that ● Originally from Russia, but lived and work in US, UK, Denmark and now in Singapore ● Follow me on Github: @lechat
  • 3. Questions ● How many jobs your Jenkins has? ● Do you run parallel build pipelines? ● Do you automate Jenkins?
  • 4. Agenda ● Save Jenkins jobs in a safe place ● Making config.xml easier to handle ● Making branch builds ● Making and running build pipelines
  • 5. I want to save my (Jenkins) job! Jenkins backup ● Jobs of course, they only exist in Jenkins and handcrafted to perfection ● Builds a history of (not so) useful information ● Keys usually forgotten essential bit of information
  • 6. I want to save my (Jenkins) job! Jenkins backup ● Jobs Trivial approach - make shell script that will put files somewhere else Another trivial approach - use Jenkins job to save Jenkins as build artefact ● Useful only as a disaster recovery Restoring just one job requires Jenkins restart (only in latest version there is an option to reload job definition)
  • 7. I want to save my (Jenkins) job! But why not keep job definition with your source code? Use jenkinsapi library to save/restore jobs! What jenkinsapi can do? ● Query Jenkins about jobs, builds, views, nodes ● Create/update jobs, views, nodes (only JNLP nodes for now) ● Execute jobs
  • 8. I want to save my (Jenkins) job! Example 1:
  • 9. Making easier to handle config.xml Editing job’s config.xml is not easy ● You need to know plugin/component internal name ● XML is too verbose ● Editing does not scale
  • 10. Making easier to handle config.xml
  • 11. Making easier to handle config.xml Use OpenStack jenkins-job-builder ● Job definition is in YAML ● Good defaults - you only need to specify overrides ● Less stuff to edit
  • 12. Making easier to handle config.xml
  • 13. Making easier to handle config.xml Jenkins-job-builder features ● Create templates for jobs ● Create variables and expand them when job is generated ● Create default values used across multiple jobs ● Define macros for repeated sections
  • 14. Making branch builds Example 3: Create jobs for each git branch
  • 15. Making job pipelines Making job pipelines is not trivial in Jenkins
  • 16. Making job pipelines Making good job pipelines is not trivial in Jenkins ● No visualization when making jobs dependencies ● Have to use “Join” plugin ● Hard to run part of the pipeline
  • 17. Making job pipelines Use jenkinsflow library to make and run pipelines
  • 19. Making job pipelines With jenkinsflow No dependencies between jobs in Jenkins You can create dynamic pipelines You can execute pipelines outside Jenkins good for building automated Git flows
  • 20. Summary All in your source code repository: ● Job definitions ● Job pipelines ● Build automation No worries about losing Jenkins instance - it can be re- created in minutes
  • 22. Reference Job creators + editors (summary) https://gist.github.com/mika/5237127 XML templates - Hudson job creator https://github.com/hudson2-plugins/jobcreator-tool Source code for this presentation https://github.com/lechat/devops-python-jenkins