Transcription
Continuous Delivery with JenkinsPipelines (incl. Advanced Topics)Roman Pickl23.05.2018join at Slido.com with #K100
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Demo1. docker run -p 8080:8080 jenkinsci/blueocean (add –p 44444:44444 or any other port to trythe ssh linter)2. Go to http://localhost:8080/3. Unlock jenkins with initialpw from log file4. Install suggested plugins (you may have to continue the process in case any plugins arebroken and update plugins later on)5. Create admin user / or continue with admin and initalpw6. Open http://localhost:8080/blue/pipelines7. Generate new Pipeline with Github repository8. Create Jenkinsfile (e.g. https://github.com/rompic/jenkinspipeline) Elektrobit (EB) 20182
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)How did I end up here?Roman Pickl (@rompic) Technical Project Manager @ Elektrobit Uses Jenkins since 2012 Loves CI/CD/DevOps Here to learn Elektrobit (EB) 20183
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Continuous Delivery (CD)Automated implementation of your system’s build, deploy, test,release process Every change results in a build Every build is a release candidate Delivery can be done at any time, on any environment Make releases a non-eventDeployment Pipeline provides: Visibility Feedback ControlRead these booksif you want toknow more!Jez Humble on Continuous Delivery(2012): https://www.youtube.com/watch?v skLJuksCRTw Elektrobit (EB) 20184
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Deployment Pipelines (Let’s build it with jenkins)Jez Humble D. F., Continuous Delivery: Reliable Software Releases Through Build, Test, and Deployment Automation (2010) Elektrobit (EB) 20185
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Jenkins#1 Continuous Integration and Delivery Server Created by Kohsuke Kawaguchi Initial Release 2005 (Hudson) Open Source (MIT License) Active and independent community (https://jenkins.io) 164,000 active installations 1,500 plugins (!) Since 2.0 Pipelines (April 2016) are first class citizens Pipeline as Code (Jenkinsfile). New User Experience “Blue Ocean” with Blue Ocean Pipeline Editor Blue Ocean 1.5 released in April -2017-jenkins-pipeline/slides.html#/meet o-blueocean-1-0/http://stats.jenkins.io/ Elektrobit (EB) 20186
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Welcome Blue Ocean! Elektrobit (EB) 20187
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Create a Pipeline Wizard1. Type of source control2. Provide access key Elektrobit (EB) 20183. Choose organization4.Choose a repository8
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)JenkinsfileWritten in a Groovy DSL“Jenkinsfile” in top level folder (different path possible since June2017 )Store in SCM (e.g. GIT) for additional benefits Code review/iteration Audit trail Single source of truthSupports two syntaxes (can be mixed) Declarative pipelines (easier; “new”; 1.0 Feb 2017) Scripted pipelines (more insfile/ Elektrobit (EB) 20189
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Scripted vs. DeclarativeScripted PipelinesDeclarative x/ Elektrobit (EB) 201810
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Scripted vs. DeclarativeScripted PipelinesDeclarative Pipeline imperative programming model declarative programming model fully featured programming environment, higher flexibility and extensibility simpler and more opinionated syntax for authoring JenkinsPipeline. very few limits Allows for validation and a visual editor for power-users and more complex requirements limits what is available to the userBoth ideal choice for simpler continuous delivery pipelines use Groovy same Pipeline sub-system underneath mostly use same steps able to utilize Shared Libraries can be mixed using the script stepS ee itional-to-pipeline/ for a more complex example of migrating a freestyle job to adeclarative/scripted ax/ Elektrobit (EB) 201811
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)script Step takes a block of Scripted Pipeline & executes that in theDeclarative Pipeline can provide a useful "escape hatch". script blocks of non-trivial size and/or complexity should bemoved into Shared ax/ Elektrobit (EB) 201812
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Settings Elektrobit (EB) 201813
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Stages Elektrobit (EB) 201814
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Parallel Execution Elektrobit (EB) 201815
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)ApprovalDeploy to Live / Release omitted here Elektrobit (EB) 201816
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Post Build Notifications Elektrobit (EB) 201817
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Blue Ocean 1.5 released Blue Ocean Plugin Latest additions– Show the downstream jobs launched with the build step– Reorder steps In pipeline editor by drag and drop– Pagination of artifacts pagePublic roadmap s://jenkins.io/blog/2018/04/18/blueocean-1-5-0/ Elektrobit (EB) 201818
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Overview Elektrobit (EB) 201819
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Approval Elektrobit (EB) 201820
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Detail Elektrobit (EB) 201821
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Multi branch support Elektrobit (EB) 201822
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Multi branch (When) Elektrobit (EB) 201823
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Pipeline Development and Advanced Tools Blue Ocean Pipeline Editor Snippet Generator Directive Generator (*NEW*) Auto-Convert Freestyle Jobs to Jenkins Pipeline Replay Feature IntelliJ IDEA GDSL – Autocomplete Command-line Pipeline Linter Jenkins File Runner (*NEW*) Unit Testing Jenkins Pipelines Shared Libaries Elektrobit (EB) 2018 Confidential24
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Pipeline Editor GitLab currently not supported (planned! ) Workaround: ipeline-editor/ Ctrl-S / Cmd-S to open the load save dialog Elektrobit (EB) 201825
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Snippet generator http://localhost:8080/pipeline-syntax Elektrobit (EB) 201826
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Declarative generator http://localhost:8080/directive-generator/ ative/ Elektrobit (EB) 201827
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Auto-Convert Freestyle Jobs to Jenkins PipelinePlugin to automatically convert Freestyle Jobs to Jenkins ps://wiki.jenkins.io/display/JENKINS/Convert To Pipeline Plugin Elektrobit (EB) 201828
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Replay FeatureGreen sub-title Allows for quick modifications and execution of an existing(valid!) Pipeline without changing the Pipeline configuration orcreating a new commit. Once you are satisfied with the changes, you can use Replay toview them again, copy them back to your Pipeline job orJenkinsfile, and then commit them using your usual engineeringprocesses Elektrobit (EB) 201829
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)IntelliJ IDEA GDSL - AutocompleteGreen sub-title Auto completion of steps for scripted pipelines Install Groovy Plugin Download http://localhost:8080/pipeline-syntax/gdsl Add it as e.g. pipeline.gdsl to your projects src 165782for setting it up. Elektrobit (EB) 201830
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Command-line Pipeline LinterValidate Declarative Pipelines from the cli before actually running it/checking it in.See linter for details. Remember to enable SSH access, expose a port on yourdocker container and add ssh key to try this! Elektrobit (EB) 201831
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)jenkinsfile-runnerSo i guess we can run now run a job in jenkins which downloads jenkins to run a jenkins job Experiment to package Jenkins pipeline execution as a commandline tool.Use cases include: Assist editing and testing Jenkinsfile locally Use Jenkins in Function-as-a-Service context Integration test shared libraries downloads latest Jenkins LTS installs plugins as defined by a plugins.txt file setup .jenkinsfile-runner directory runs Jenkins master headless run a single job based on a local Jenkinsfile, then shutdown e-runner Elektrobit (EB) 201832
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Shared LibrariesGreen sub-titleShare parts of Pipelines between various projects to reduceredundancies and keep code "DRY“.Functions can than be called from r more details. Elektrobit (EB) 201833
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Unit Testing Jenkins Pipelines Allows to unit test Pipelines and Shared Libraries before running them in full Provides a mock execution environment that can be used to check for expected behavior Still quite rough around the edges. (e.g. no support for declarative pipeline t/pull/13) See: https://github.com/lesfurets/JenkinsPipelineUnit lob/master/README.md https://issues.jenkins-ci.org/browse/JENKINS-33925 Elektrobit (EB) 2018 Confidential34
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Things missing / Things to come Missing:– Support for definition of variables in declarative pipelines (see workaround in )– Keep build forever 8; workaround via shared lib, change to be released)– Restart stages for pipelines (checkpoint as commercial feature, https://issues.jenkins-ci.org/browse/JENKINS-33846 ; feature for declarative pipelinesplanned: ) To Come:– More editor coverage of declaration syntax– GitLab read/write support– Jenkins Essentials– Project Cheetah https://jenkins.io/blog/2018/02/22/cheetah/– For more see https://jenkins.io/projects/blueocean/roadmap/ Elektrobit (EB) 201835
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Further references & information I Website: https://jenkins.io Blog: https://jenkins.io/node/ pipelines Getting Started https://jenkins.io/doc/book/getting-started/ https://jenkins.io/doc/book/pipeline/syntax/ https://jenkins.io/doc/tutorials/ https://jenkins.io/doc/pipeline/steps/ ted/ tion-plugin/wiki/getting%20started ols/ Elektrobit (EB) 201836
Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)Further references & information IIDocker Files: ADME.md https://hub.docker.com/r/jenkinsci/blueocean/ Elektrobit (EB) 201837
Get in touch!Roman Pickl com
Jez Humble D. F., Continuous Delivery: Reliable Software Releases Through Build, Test, and Deployment Automation (2010) Deployment Pipelines (Let's build it with jenkins) Continuous Delivery with Jenkins Pipelines (incl. Advanced Topics)