see slides
-
Upload
vuongxuyen -
Category
Documents
-
view
223 -
download
3
Transcript of see slides
![Page 1: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/1.jpg)
Continuous Delivery as Codewith Jenkins Workflow
Jesse Glick, CloudBees (@tyvole)
![Page 2: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/2.jpg)
Jenkins Workflow as Code
![Page 3: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/3.jpg)
Why Workflow?
• Complex build/test/deploy pipelines• traditional Jenkins projects too rigid• sometimes need custom logic
• Stages, human input, parallelism, …• Long-running build steps survive Jenkins restarts
![Page 4: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/4.jpg)
Why “as code”?
• Overall job definition is a script• calls your build tools and scripts for details
• Script can be versioned alongside project sources• experimental branches• code review!
• Keep less configuration in $JENKINS_HOME
![Page 5: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/5.jpg)
Docker
![Page 6: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/6.jpg)
Workflow plugin for Docker
• Simple entry point to Docker-related functions• Build images from Dockerfile• Test images in temporary containers• Push to Docker Hub or private Docker registry
![Page 7: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/7.jpg)
Docker as a build environment
• Run build steps inside a container!• use a standard image from Docker Hub• or from your company’s registry• or build it from project sources
• Use generic Linux slaves• Reproduce CI environment on your laptop• Empowers developers to use the right tools
docker.image('maven:3.3.3-jdk8').inside {sh 'mvn verify'}
![Page 8: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/8.jpg)
Custom DSLs
![Page 9: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/9.jpg)
Defining new variables
• workflowLibs.git holds sitewide definitions• Had a src dir to define classes• Now supports a vars subdirectory• Scripts here can act like global variables
• create a new DSL entry point, like docker
![Page 10: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/10.jpg)
Defining new functions
• Vars act as functions, if you define a call method• like defining a new step, but in Groovy!
• Groovy builder pattern also possible• use: myThing {prop = 'value'}
![Page 11: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/11.jpg)
Building multiple branches
![Page 12: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/12.jpg)
• Can use branch wildcards in Git (etc.)• mixes up changelog, status, test results• no way to adjust build steps per branch
• Can create one project per branch• painful to maintain without extra tools
• Most people need this!
Why can’t Jenkins branch?
![Page 13: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/13.jpg)
Multibranch workflows
• Branch with a Jenkinsfile → one subproject• that is your Workflow script• just checkout scm to get full source tree
• Can edit Jenkinsfile in your branch• revision matches sources
![Page 14: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/14.jpg)
Branch sources
• Generic repository inspection• Git• Subversion• Mercurial
• Dedicated GitHub support• faster inspection using GitHub API• webhooks for instant notification
![Page 15: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/15.jpg)
CJP extra branch sources
• Extended GitHub support• pull requests• commit status notification
• BitBucket• similar to GitHub
• Proposed integrations• Stash• Gerrit• validated merge
![Page 16: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/16.jpg)
Organization folders
![Page 17: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/17.jpg)
Organization folders
• Before: custom scripting just to add all 100 repos• New folder type: “organization”
• each item is a multibranch Workflow project• adds/removes projects automatically
• Only configuration is org name + credentials• one step closer to “code as config”
![Page 18: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/18.jpg)
Organization types
• GitHub (organization or user)• private repositories supported• GitHub Enterprise
• CJP: BitBucket, Stash proposed
![Page 19: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/19.jpg)
What to expect
![Page 20: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/20.jpg)
Available now
• Released to update center• Git, Subversion, Mercurial integrations• Workflow custom DSLs (1.10)• CloudBees Docker Workflow• Multi-Branch Project (freestyle)
• Experimental update center• Workflow: Multibranch• Literate, YAML Project (declarative)
![Page 21: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/21.jpg)
Coming soon
• To experimental update center• Organization folders incl. Workflow provider • GitHub integration
• To CJP experimental update center• GitHub pull requests• BitBucket integration
![Page 22: see slides](https://reader034.fdocuments.net/reader034/viewer/2022051302/5875e5e21a28ab00638ba56a/html5/thumbnails/22.jpg)
Future directions
• Cleanup before 1.0: UI, APIs, minor features• GitHub: one-step OAuth & webhook setup• Autobuild any pom.xml, Rakefile, …• Specify job properties in Jenkinsfile
• parameters, concurrency, …• Restricted build scripts for pull requests