O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

7 Habits of Highly Effective Jenkins Users

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Carregando em…3
×

Confira estes a seguir

1 de 50 Anúncio
Anúncio

Mais Conteúdo rRelacionado

Diapositivos para si (20)

Semelhante a 7 Habits of Highly Effective Jenkins Users (20)

Anúncio

Mais de Jules Pierre-Louis (18)

Mais recentes (20)

Anúncio

7 Habits of Highly Effective Jenkins Users

  1. 1. ©2016CloudBees,Inc.AllRightsReserved © 2016 CloudBees, Inc. All Rights Reserved
  2. 2. ©2016CloudBees,Inc.AllRightsReserved © 2016 CloudBees, Inc. All Rights Reserved 7 Habit of Highly Effective Jenkins Users Brian Dawson, CloudBees
  3. 3. ©2016CloudBees,Inc.AllRightsReserved Who Am I? • Brian Dawson • 20+ Years as Developer, CI/CD Consultant, etc • Currently DevOps Dude and Jenkins Product Marketing at CloudBees
  4. 4. ©2016CloudBees,Inc.AllRightsReserved What’s This Talk About? • These are lesson colleagues and I learned from:  Implementing Jenkins to support CI/CD for clients  Maintaining multiple large Jenkins instances over the years.  Working on Jenkins itself and many of its plugins.  Seeing customer usage in the real world.  Discuss with and observations of the market
  5. 5. ©2016CloudBees,Inc.AllRightsReserved Your Mileage May Vary • These habits can be valuable on every Jenkins instance. • Some will be more relevant for larger instances, those with more complex jobs, and/or production-critical instances. • But these are *our* recommendations - you need to learn what’s best for your Jenkins setup.
  6. 6. ©2016CloudBees,Inc.AllRightsReserved MAKE YOUR MASTER STABLE AND RESTORABLE HABIT 1
  7. 7. ©2016CloudBees,Inc.AllRightsReserved Use LTS Releases • LTS release trains created every 12 weeks. • Active train updated three times before the next one starts. • Avoid bleeding edge instability. • LTS releases go through automated acceptance testing and a manual testing matrix before going out.
  8. 8. ©2016CloudBees,Inc.AllRightsReserved Jenkins 2.0 LTS! • Jenkins 2.x LTS line (2.19.x) has been out for a few months. • Now's a great time to switch!.
  9. 9. ©2016CloudBees,Inc.AllRightsReserved Be Conservative About Upgrading Plugins • Plugins can change a lot without it being obvious. • Backwards compatibility can sometimes break.  Example - Extended Email plugin recipient/trigger settings in 2014.  Even the Green Balls plugin broke recently! Really! • New features can be unstable/problematic in the wild.
  10. 10. ©2016CloudBees,Inc.AllRightsReserved Have an Upgrade Testbed • Test out upgrades and new plugins in a testbed environment before going live in production. • Set up jobs to cover your plugin usage. • If possible, test your usage at scale. • Give significant changes a few days, at least, of builds running before going live.
  11. 11. ©2016CloudBees,Inc.AllRightsReserved Back Up Your Configuration • Kind of obvious, But how many of us are as good about this as we should be? • Lots of possible solutions  Within Jenkins, maybe the thinBackup plugin.  Full copies of $JENKINS_HOME work great, but can be slow and use lots of disk.  Config files can be copied without copying all the builds, etc as well - see an example here  CloudBees has commercial solutions too!
  12. 12. ©2016CloudBees,Inc.AllRightsReserved Avoid Using The Maven Job Type • Maven build steps are perfectly fine in freestyle jobs, but the Maven plugin’s Maven job type is…questionable. • Implementation leads to some potential problems: • plugin compatibility • lazy loading of projects and performance side effects • interception of Maven execution internals, etc… • I’ve seen a lot of strange edge case problems show up with it at scale. Be careful with it.
  13. 13. ©2016CloudBees,Inc.AllRightsReserved BREAK UP THE BLOAT HABIT 2
  14. 14. ©2016CloudBees,Inc.AllRightsReserved Multiple Masters • If you have a lot of projects and teams, multiple masters give you a lot more agility and control. • Split up masters by team, function, access, etc. • Makes it easier to restart for plugin installs/upgrades, etc without disrupting everyone. • More masters with less jobs each are more stable, less prone to edge case bugs.
  15. 15. ©2016CloudBees,Inc.AllRightsReserved Break Up Or Transform Your Jobs • Modularization and reuse are good in programming - and good in Jenkins too. • Multi-job builds allow reusability of generic jobs across multiple projects, releases, etc. • Pipeline doesn’t break up your jobs, but makes your large jobs more understandable and durable.
  16. 16. ©2016CloudBees,Inc.AllRightsReserved Tools For Breaking Up Your Jobs • Just some examples - there are a ton of ways you are able to do this in traditional Jenkins jobs. • Parameterized Trigger + Conditional Build Step • Copy Artifact • Promoted Builds • …  Very powerful, not as easy to configure.
  17. 17. ©2016CloudBees,Inc.AllRightsReserved Tools For Transforming Your Jobs • Pipeline plugin:  Define your job in a DSL.  Check the Jenkinsfile into your repository  Pipeline as Code!  One job can do far more - run steps on different nodes, check out multiple repositories…  More on this later!
  18. 18. ©2016CloudBees,Inc.AllRightsReserved JENKINS TASKS AS CODE! HABIT 3
  19. 19. ©2016CloudBees,Inc.AllRightsReserved The Script Console And Scriptler • Why do things by hand? • Get deep into Jenkins itself - control the internals and get full visibility of what’s happening. • Access the entire Jenkins model - make changes to jobs, find problem configurations and more. • Use Scriptler to store and share Groovy scripts for reuse. • Public catalog at https://github.com/jenkinsci/jenkins-scripts
  20. 20. ©2016CloudBees,Inc.AllRightsReserved Some Examples From The Scriptler Catalogs… • Disable/enable jobs matching a pattern • Clear the build queue • Set log rotation/discard old builds configuration across all jobs • Disable SCM polling at night across all jobs • Run the log rotator (actually discard old builds) for all jobs • etc…
  21. 21. ©2016CloudBees,Inc.AllRightsReserved Generate Jobs From Code • Jenkins REST API and CLI let you post new jobs and changes to jobs. • You can define your whole job and/or set of multiple jobs in a DSL or through a plugin that translates configuration into job execution.
  22. 22. ©2016CloudBees,Inc.AllRightsReserved Some DSL-ish Plugins • Job DSL plugin  Full Groovy DSL for job definitions - check in your DSL and create your jobs as a build step.  Work is underway to standardize simple DSL syntax for both Job DSL and Pipeline! • Job Builder plugin  Translates simple YAML or JSON descriptions into jobs.
  23. 23. ©2016CloudBees,Inc.AllRightsReserved Pipeline Plugin • Define multiple complex steps in just one relatively simple scripting DSL. • Pipeline as Code • Check your build into your repo as a Jenkinsfile • Auto-discovery and creation of build jobs with Multibranch support for GitHub! • Declarative Pipeline for simpler configuration-based approach coming…more tomorrow
  24. 24. ©2016CloudBees,Inc.AllRightsReserved A Bit More On Pipeline… • Some other key features -  Durability - build tasks survive Jenkins master restarts!  Visualization for your Pipeline - see how long individual stages took, logs for single stages and more.  Share functions across all your jobs using the Pipeline Shared Libraries feature.  Blue Ocean - a new UI for Jenkins, built for Pipeline, now in beta!  Pipeline is the direction Jenkins is going - come on board!
  25. 25. ©2016CloudBees,Inc.AllRightsReserved Dear Mr. Jenkins, There are too many plugins these days. Please eliminate three hundred. P.S. - I am not a crackpot.
  26. 26. ©2016CloudBees,Inc.AllRightsReserved Do You Really Need That Plugin? • Don’t install plugins on the master if you aren’t going to actually use them. • Lots of duplication of functionality across plugins - pick the right one for the job. • Plugins can cause instability in areas you don’t expect, and can add to load and run time for jobs - why take a hit from plugins you don’t use?
  27. 27. ©2016CloudBees,Inc.AllRightsReserved Clean Up Old Plugins And Their Data • Uninstall unused/unneeded plugins. • In Manage Jenkins, watch for the note about old data - clear it out when you uninstall plugins, to slim down your job and build config files. • Speeds up loading of the master and individual jobs.
  28. 28. ©2016CloudBees,Inc.AllRightsReserved My essential plugins (besides Pipeline!) • Job Config History • Disk Usage  Not any more - newer versions don’t scale well at all! • Static analysis plugins • xUnit  Translates lots of test output into junit format for Jenkins to consume.
  29. 29. ©2016CloudBees,Inc.AllRightsReserved My essential plugins • Parameterized Trigger and Conditional Build Step  Used to be my Swiss Army Knife for build workflows!  Now, though? Pipeline! • Pipeline Stage View  Visualization of your Pipeline build. • Timestamper  Need to know when something in the build log actually happened? This plugin annotates each line in the log with the time it was seen.
  30. 30. ©2016CloudBees,Inc.AllRightsReserved My essential plugins • Rebuild  Re-run parameterized builds easily. • Build Timeout  Builds hang. This plugin deals with hung builds.
  31. 31. ©2016CloudBees,Inc.AllRightsReserved Pipeline and other plugins • Some of these plugins aren’t needed in Pipeline. • Functionality is built in instead. • EnvInject, Rebuild, Build Timeout… • And who needs a plugin for conditionals when you’ve got “if (foo) { … }”? • Not all plugins for Freestyle jobs make sense for Pipeline. • Different ways of doing things mean different implementations.
  32. 32. ©2016CloudBees,Inc.AllRightsReserved Don’t Take My Word For It • These are *my* essential plugins, from my experience and for my use cases. • You may not need these plugins, you may need other plugins completely. • But these are plugins I think have a lot of versatility and value, and little risk.
  33. 33. ©2016CloudBees,Inc.AllRightsReserved Remember The Global Configuration • Some plugins have global configuration settings you should remember to look at. • The defaults may not always work for you - and sometimes the defaults aren’t great choices. • Job Config History, for example  By default, saves “changes” for every Maven module separately! Ouch!
  34. 34. ©2016CloudBees,Inc.AllRightsReserved INTEGRATE WITH OTHER TOOLS AND SERVICES HABIT 5
  35. 35. ©2016CloudBees,Inc.AllRightsReserved Jenkins Plays Nicely With Others • Thanks to Jenkins’ plugins and REST API, services and tools can easily interact with Jenkins and vice versa. • Trigger builds based on GitHub pull requests, update JIRA upon successful builds and much, much more. • I’ll only touch on a few such tools and services - you can find many more on the Jenkins wiki.
  36. 36. ©2016CloudBees,Inc.AllRightsReserved Source Control! …well, yeah. Moving on…
  37. 37. ©2016CloudBees,Inc.AllRightsReserved Gerrit And GitHub Pull Requests • Gerrit Trigger, GitHub Pull Request Builder, Pipeline Multibranch GitHub support - all very useful. • Build every proposed change, report back to the review tool. • With this, you can enable automatic merging of changes, promotion from branch to branch, and much more.
  38. 38. ©2016CloudBees,Inc.AllRightsReserved Multibranch Pipelines and Organization Folders • Point at a repo (GitHub, Bitbucket, etc), jobs are created for every branch and pull requests, automatically. • GitHub organization folders are the next level up - point at an org, get Multibranch Pipelines for each repo in the org!
  39. 39. ©2016CloudBees,Inc.AllRightsReserved JIRA • Update JIRA issues when commits with messages containing the issues are built. • Follow build fingerprints to update issues in related projects as well. • Generate JIRA release notes as part of the build process.
  40. 40. ©2016CloudBees,Inc.AllRightsReserved Docker - The New Hotness • Everyone loves Docker these days! • Various Jenkins Docker plugins  Build Docker images  Run builds in Docker containers  Traceability of containers  Integrate with container providers - Mesos, AWS ECS, Kubernetes!  All smoothly working with Pipeline!
  41. 41. ©2016CloudBees,Inc.AllRightsReserved MAKE YOUR AGENTS FUNGIBLE HABIT 6
  42. 42. ©2016CloudBees,Inc.AllRightsReserved Fungible? What Does That Mean? • “Fungibility is the property of a good or a commodity whose individual units are capable of mutual substitution.” • A fungible agent is a agent you can replace easily with another agent. • If one dies or is busy, no problem - just add another one. • The easier it is to add agents, the easier your life is.
  43. 43. ©2016CloudBees,Inc.AllRightsReserved How Do You Make Your Agents Fungible? • I have no opinion on which config management tool to use. • To be honest, it doesn’t really matter. • Anything that can set up your environment consistently is good enough!
  44. 44. ©2016CloudBees,Inc.AllRightsReserved Reusability And Flexibility • Try to make your agents general purpose. • Don’t make them customized solely for use by one job or set of jobs if you can avoid it.  Interchangeable agents allow for more efficient usage.
  45. 45. ©2016CloudBees,Inc.AllRightsReserved Reusability And Flexibility • If you need specific custom agents, make them on- demand.  Don’t tie up static resources with agents that won’t be used all the time.
  46. 46. ©2016CloudBees,Inc.AllRightsReserved To The Cloud! • More efficient usage of your resources. • Private cloud, public cloud, Docker containers, whatever  The goal is to avoid idle resources that can’t be used for anything else. • Pre-bake your cloud agent images - faster startup time, more consistency.
  47. 47. ©2016CloudBees,Inc.AllRightsReserved JOIN THE COMMUNITY HABIT 7
  48. 48. ©2016CloudBees,Inc.AllRightsReserved Get Involved! • Write plugins.  Extend existing plugins! • Open JIRAs. • Fix bugs. • Get help on the mailing lists or IRC. • Help others too!
  49. 49. ©2016CloudBees,Inc.AllRightsReserved QUESTIONS?
  50. 50. ©2016CloudBees,Inc.AllRightsReserved THANK YOU FOR ATTENDING!

Notas do Editor

  • EnvInject has its haters - it has bloated over the years, with a ton of features that are rarely used. But for non-Pipeline jobs, it’s still the best way to manage the environment.

×