einfach definieren Delivery Pipelines in Jenkins mit Workflow · PDF fileDelivery Pipelines in...
Transcript of einfach definieren Delivery Pipelines in Jenkins mit Workflow · PDF fileDelivery Pipelines in...
Delivery Pipelines in Jenkins mit Workflow einfach definieren
Bernhard CyganSenior Solution ArchitectCloudBees
Über CloudBees
© 2015 CloudBees, Inc. All Rights Reserved
© 2015 CloudBees, Inc. All Rights Reserved
© 2015 CloudBees, Inc. All Rights Reserved
© 2015 CloudBees, Inc. All Rights Reserved
© 2015 CloudBees, Inc. All Rights Reserved
© 2015 CloudBees, Inc. All Rights Reserved
© 2015 CloudBees, Inc. All Rights Reserved
Einige CloudBees Kunden
3
Financial Services Technology Retail Consumer Embedded
Jenkins is the Hub of the CI/CD Ecosystem
On-premise or in the cloud
Plug-ins for all your tools
RunDeployStageTestBuildCommit
Continuous Delivery (CD) automatisiert den Application Lifecycle
BuildCommit Test Stage Deploy
Feedback Loop
CD beginnt mit Continuous Integration (CI): Automating Application Build and Test
Continuous Integration
ProdDev
Automation Engine
Developer
Source Code
Control System
Compile/BuildCode
Scan TestsCodeCommit
Results Report
BuildCommit Test
Automation Engine
Developer
Source Code
Control System
Compile/BuildCode
Scan TestsCodeCommit
Results Report
CD wendet Automatisierung auf den gesamten Lifecycle an
BuildCommit Test Stage Deploy
Deploy Prod
Deploy Stage
Complex Delivery Pipelines
Delivery of App and Config
Enterprise-grade CD Automation Platform
Continuous Delivery
ProdDev
Developer
Source Code
Control System
CodeCommit
CD bedeutet: Pipelines für Application Code zu definieren
BuildCommit Test Stage Deploy
Continuous Delivery
ProdDev
BuildCommit Test Stage Deploy
BuildCommit Test Stage Deploy
BuildCommit Test Stage Deploy
DeployStageTest
Deploy
Build
StageTestBuild
DeployStageTestBuild
DeployStageTestBuild
Ausführen, Überwachen, und Feedback geben
Commit ProdDev
Commit
Commit
Commit
Continuous Delivery
Developer
Source Code
Control System
CodeCommit
Both CI and CD extend the Agile software development methodology to allow small, incremental software changes to be made
available for delivery continuously.
Faster Feature Delivery
Lower Risk from Failure
Lower Error Rate in Production
Happier Customers
Jenkins Workflow ist der Schlüssel zu Continuous Delivery
Developer
Source Code
Control System
Compile/BuildCode
Scan TestsCodeCommit
Results Report
BuildCommit Test Stage Deploy
Deploy Prod
Deploy Stage
Complex Delivery Pipelines
Delivery of App and Config
Jenkins Workflow
ProdDev
Jenkins Workflow Pipelines – komplex und robust
Jenkins Workflow
ProdDevPerf Test
BuildCommit Selenium Test Stage Deploy
Sonar Test
Pipelines Need:• Branching• Looping• Restarts• Checkpoints• Manual Input
CloudBees Jenkins Workflow Stageview
ProdDevJenkins Workflow
Developer
Source Code
Control System
CodeCommit
Wie sieht das in der Workflow DSL aus ?stage ‘Build’
doBuild('https://github.com/harniman/spring-petclinic.git')checkpoint ‘Build complete’
stage name : ‘QA and performance’, concurrency : 1 parallel (
qualityAnalysis : {doQA(),
performanceTest: {doPerformanceTest()
})
stage ‘Staging’doStaging(‘petclinic.war’)
checkpoint ‘Staging ready’
Jenkins Workflow - Stage ‘Build’def doBuild (src,warname) {
stage ‘Build’ node(‘linux’) {
echo "INFO - Starting build phase"git url: src
ensureMaven()sh 'mvn -o clean package'sh 'tar -c -f src.tar src/ pom.xml'archive 'src.tar, target/warname'step $class: 'hudson.tasks.junit.JUnitResultArchiver', testResults: 'target/surefire-reports/*.xml'echo "INFO - Ending build phase"
}}
Jenkins Workflow - Stage ‘Staging’def doStaging (warname) {
checkpoint 'CHOOSE TO ENTER STAGING'
input message: "Does staging app http://localhost:$qaHttpPort/ look good? If yes, we deploy on staging.", ok: "DEPLOY TO STAGING!"
node('linux') {// DEPLOY ON STAGINGecho "INFO - Starting Staging Deploy"unarchive mapping: ['target/app.war': warname]deployApp "$warname", stagingCatalinaBase, stagingHttpPortecho "Application is available on STAGING at http://localhost:$stagingHttpPort/"echo "INFO - Ending QA Deploy"
}}
Jenkins Workflow - als Templatestage ‘Build’
doBuild(scmsrc,warname)checkpoint ‘Build complete’
stage name : ‘QA and performance’, concurrency : 1 parallel (
qualityAnalysis : {doQA(),
performanceTest: {doPerformanceTest()
})
stage ‘Staging’doStaging(warname)
checkpoint ‘Staging ready’
Jenkins Workflow - Template in JenkinsDie Template-Definition sieht wie eine normale Build-Konfiguration aus, enthält aber zusätzlich die gewünschten Parameter:
Jenkins Workflow - Nutzung des TemplatesDie vom Template abgeleitete Job-Konfiguration sieht jetzt so aus:
Das ist wirklich alles, was man jetzt noch konfigurieren muß. Eine einfach Methode, um Best Practices oder Compliance-Anforderungen zu implementieren, da die Jobs vom Template erben. Das bedeutet, daß sich Änderungen am Template sofort auf den nächsten Build Run auswirken.
if ( hasInternet() and enoughTimeRemains() ) doLiveDemo()
20
Demo
21
PointersDocumentation from the source https://github.com/jenkinsci/workflow-plugin/blob/master/TUTORIAL.md
Getting started with Workflowhttp://udaypal.com/jenkins-workflow-getting-started/
Introduction to workflow http://www.sitepoint.com/supercharge-continuous-delivery-jenkins-workflow-plugin/
Introduction to workflowhttps://www.youtube.com/watch?v=Welwf1wTU-w
Jenkins Cookbookhttp://documentation.cloudbees.com/docs/cookbook/_continuous_delivery_with_jenkins_workflow.html
Danke für Ihre Aufmerksamkeit!
www.cloudbees.com