Successfully reported this slideshow.
Your SlideShare is downloading. ×

Jenkins at your continuous service

Jenkins at your continuous service

Download to read offline

Jenkins is always ready to serve your software delivery automation needs. And even though there are other alternatives, it is considered a de facto tool that many teams turn to when they need simplicity and rich set of features for their automation. This talk will give an overview of Jenkins ecosystem and its capabilities. As well as it will provide some tips and tricks on what you probably didn't know about Jenkins and it's use cases.

Jenkins is always ready to serve your software delivery automation needs. And even though there are other alternatives, it is considered a de facto tool that many teams turn to when they need simplicity and rich set of features for their automation. This talk will give an overview of Jenkins ecosystem and its capabilities. As well as it will provide some tips and tricks on what you probably didn't know about Jenkins and it's use cases.

More Related Content

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Jenkins at your continuous service

  1. 1. 01
  2. 2. About me Bio: Developer, coach, speaker, author Company: Aestas/IT (http://aestasit.com) E­mail: andrey@aestasit.com Linkedin: http://www.linkedin.com/in/andreyadamovich Lanyrd: http://lanyrd.com/profile/andrey­adamovich GitHub: https://github.com/aadamovich SO: http://stackoverflow.com/users/162792/andrey­adamovich Twitter: @codingandrey, @aestasit • • • • • • • • 02
  3. 3. Let's start! 03
  4. 4. Who is mr. Jenkins? 04
  5. 5. A bit of history: Hudson Work started in the summer of 2004 at Sun by Kohsuke Kawaguchi. First release: February 2005. In May, 2008, Hudson won the Duke's Choice Award in the Developer Solutions category. In 2010, Sun is acquired by Oracle... discussions, negotiations. Kohsuke Kawaguchi leaves Oracle. • • • • • 05
  6. 6. A bit of history: Jenkins In 2010, majority of Hudson's community votes for forking and name changing. Initial release of Jenkins: 2nd of February, 2011. Oracle still supports and develops Hudson. Around 2010­2011, CloudBees is created and declared Jenkins as its backbone product. • • • • 06
  7. 7. Current state Latest version:  1.651  (LTS:  1.642.2 ). jenkinsci  organization on Github has 600+ members ... and over 1400 Git repositories. 1100+ plugins available. Uncountable number of installations and users. Jenkins 2.0, most likely, is coming this year. • • • • • • 07
  8. 8. Vibrant and lively 08
  9. 9. Jenkins is useful for... Building (compiling, assembling, linking, etc.)... ...and Reporting the build status. Testing and, more importantly, Reporting the test results. Releasing, Deploying, Provisioning... ...or simply ­ Executing any of your automation tasks. So... Jenkins is an ultimate control panel for your software delivery! • • • • • • • 09
  10. 10. Tools using/integrating with Jenkins Fabric8 ­ http://fabric8.io/ MaestroDev ­ http://maestrodev.wix.com/maestrodev IBM BlueMix ­ https://hub.jazz.net/ XebiaLabs ­ https://xebialabs.com/ • • • • 10
  11. 11. Starting Jenkins java ‐jar jenkins.war01. 11
  12. 12. Starting Jenkins: Debian wget ‐q ‐O ‐       https://jenkins‐ci.org/debian/jenkins‐ci.org.key |       sudo apt‐key add ‐ sudo sh ‐c 'echo deb       http://pkg.jenkins‐ci.org/debian binary/       > /etc/apt/sources.list.d/jenkins.list' sudo apt‐get update sudo apt‐get install jenkins 01. 02. 03. 04. 05. 06. 07. 08. 12
  13. 13. Starting Jenkins: RedHat sudo wget ‐O /etc/yum.repos.d/jenkins.repo       http://pkg.jenkins‐ci.org/redhat‐stable/jenkins.repo sudo rpm ‐‐import       https://jenkins‐ci.org/redhat/jenkins‐ci.org.key sudo yum install jenkins 01. 02. 03. 04. 05. 13
  14. 14. Good start, but... 14
  15. 15. What's the first thing you do...15
  16. 16. in Jenkins after installation?16
  17. 17. Remove The Blue Balls! 17
  18. 18. Green balls 18
  19. 19. Green balls 19
  20. 20. But if seriously... 20
  21. 21. Jenkins has lots of plugins 21
  22. 22. Jenkins needs to be maintained!22
  23. 23. Maintaining your installation Developers need more tools to build their software. Developers need more plugins to better integrate build tools and increase visibility. Developers need faster feedback from their builds. It's not enough to just start the WAR file! • • • • 23
  24. 24. Installing Jenkins: better way For more reliable setup, it's better to use provisioning tools to describe your requirements: Puppet Chef Ansible your favorite provisioning tool here • • • • 24
  25. 25. Installing Jenkins: Puppet https://forge.puppetlabs.com/rtyler/jenkins class { 'jenkins':   executors => 4, } jenkins::plugin { 'git':    version => '1.1.11', } 01. 02. 03. 04. 05. 06. 25
  26. 26. Installing Jenkins: Puppet https://forge.puppetlabs.com/rtyler/jenkins jenkins::job { 'test‐build‐job':   enabled => 0,   config  =>      template("${templates}/test‐build‐job.xml.erb"), } 01. 02. 03. 04. 05. 26
  27. 27. Installing Jenkins: Ansible https://github.com/geerlingguy/ansible­role­jenkins ‐ hosts: ci‐server   vars:     jenkins_plugins:       ‐ git       ‐ ssh   roles:     ‐ geerlingguy.jenkins 01. 02. 03. 04. 05. 06. 07. 27
  28. 28. Installing Jenkins: Chef https://github.com/chef­cookbooks/jenkins include_recipe 'jenkins::master' jenkins_plugin 'greenballs' do   version '1.3' end jenkins_user 'grumpy' do   action :delete end 01. 02. 03. 04. 05. 06. 07. 28
  29. 29. Installing Jenkins: Docker docker run ‐p 8080:8080 ‐p 50000:50000         ‐‐name myjenkins         ‐‐env JAVA_OPTS=...         ‐v /var/lib/jenkins:/var/jenkins_home         jenkins 01. 02. 03. 04. 05. 29
  30. 30. Installing Jenkins: Dockerfile FROM jenkins COPY plugins.txt /usr/share/jenkins/ref/ COPY custom.groovy       /usr/share/jenkins/ref/init.groovy.d/custom.groovy RUN  /usr/local/bin/plugins.sh       /usr/share/jenkins/ref/plugins.txt 01. 02. 03. 04. 05. 06. 30
  31. 31. Configuring Jenkins 31
  32. 32. JobConfigHistory https://wiki.jenkins­ci.org/display/JENKINS/JobConfigHistory+Plugin 32
  33. 33. Jenkins as Code 33
  34. 34. Job DSL https://jenkinsci.github.io/job­dsl­plugin/ job(jobName) {   scm {     git("git://github.com/${project}.git", branchName)   }   steps {     maven("test ‐Dproject.name=${project}/${branchName}")   } } 01. 02. 03. 04. 05. 06. 07. 08. 34
  35. 35. Gradle Jenkins plugin https://github.com/ghale/gradle­jenkins­plugin Allows defining jobs and views with the help of Job DSL inside Gradle build. Gives common tasks to create, update, delete jobs and views on Jenkins server(s). • • • 35
  36. 36. Gradle Jenkins plugin apply plugin: 'com.terrafolio.jenkins' jenkins {   servers {     testing {       url 'http://jenkins.somewhere.com:8080'     }   }   ... 01. 02. 03. 04. 05. 06. 07. 08. 36
  37. 37. Gradle Jenkins plugin: definition   ...   jobs {     test {       server servers.testing       definition {         name "Build ${project.name}"         xml file('config.xml')       }     }}} 01. 02. 03. 04. 05. 06. 07. 08. 09. 37
  38. 38. Gradle Jenkins plugin: templates templates {   build_template {     dsl {       triggers { scm '*/5 * * * *' }       steps { gradle 'clean build' }       publishers {         archiveJunit 'build/test‐results/*.xml'         archiveArtifacts 'build/libs/*.jar'       }}}} 01. 02. 03. 04. 05. 06. 07. 08. 09. 38
  39. 39. Gradle Jenkins plugin: mixing jobs {  for (i in 1..3) {   "build${i}" {    dsl {     using 'build_template'     customWorkspace "/workspaces/build${i}"     scm {       git("git@git.somewhere.com/build_repo_${i}")     }  }}}} 01. 02. 03. 04. 05. 06. 07. 08. 09. 10. 39
  40. 40. Gradle Jenkins plugin: views view {   name "Even jobs"   jobs {     name "Build Job 2"    }    columns {     name()     buildButton()   }} 01. 02. 03. 04. 05. 06. 07. 08. 09. 40
  41. 41. Gradle Jenkins plugin: tasks updateJenkinsItems deleteJenkinsItems dumpJenkinsItems dumpRemoteJenkinsItems retireJenkinsItems validateJenkinsItems • • • • • • 41
  42. 42. Constructing pipelines 42
  43. 43. Build Flow https://wiki.jenkins­ci.org/display/JENKINS/Build+Flow+Plugin 43
  44. 44. Build Flow: simple build("job2A") build("job2B") build("job2C") 01. 02. 03. 44
  45. 45. Build Flow: guard guard {   build( "this_job_may_fail" ) } rescue {   build( "cleanup" ) } 01. 02. 03. 04. 05. 45
  46. 46. Build Flow: retry retry (3) {   build( "this_job_may_fail" ) } 01. 02. 03. 46
  47. 47. Build Flow: parallel parallel (   // job 1, 2 and 3 will    // be scheduled in parallel.   { build("job1") },   { build("job2") },   { build("job3") } ) // job4 will be triggered after jobs 1, 2, 3 complete build("job4") 01. 02. 03. 04. 05. 06. 07. 08. 09. 47
  48. 48. Build Flow: parallel parallel ( {     build("job1A")     build("job1B") }, {     build("job2A")     build("job2B") } ) 01. 02. 03. 04. 05. 06. 07. 08. 09. 10. 48
  49. 49. Build Pipeline https://wiki.jenkins­ci.org/display/JENKINS/Build+Pipeline+Plugin 49
  50. 50. Reporting 50
  51. 51. Timestamper https://wiki.jenkins­ci.org/display/JENKINS/Timestamper 21:51:15  Started by user anonymous 21:51:15  Building on master 21:51:17  Finished: SUCCESS 01. 02. 03. 51
  52. 52. ANSI Color https://wiki.jenkins­ci.org/display/JENKINS/AnsiColor+Plugin 52
  53. 53. TAP 53
  54. 54. Test Anything Protocol TAP, the Test Anything Protocol, is a simple text­based interface between testing modules in a test harness. TAP started life as part of the test harness for Perl but now has implementations in C, C++, Python, PHP, Perl, Java, JavaScript, and others. 54
  55. 55. TAP format: simple 1..2 ok 1 ‐ Yahoo! not ok 2 ‐ org.tap4j.Error... 01. 02. 03. 55
  56. 56. TAP format: nested 1..2 ok 1 ‐ First test   1..2   ok 1 ‐ This is a subtest   ok 2 ‐ So is this     1..2     ok 1 ‐ This is a subtest     ok 2 ‐ So is this ok 2 ‐ 2nd test 01. 02. 03. 04. 05. 06. 07. 08. 09. 56
  57. 57. TAP for Jenkins https://wiki.jenkins­ci.org/display/JENKINS/TAP+Plugin 57
  58. 58. TAP for Jenkins 58
  59. 59. Jenkins TV https://wiki.jenkins­ci.org/display/JENKINS/Build+Monitor+Plugin 59
  60. 60. Jenkins TV 60
  61. 61. Custom warnings https://wiki.jenkins­ci.org/display/JENKINS/Warnings+Plugin 61
  62. 62. Custom warnings Support for javac (ant, maven, command line), Eclipse Java Compiler, JavaDoc Compiler, Hudson/Jenkins HPI, MSBuild, GCC, GNU Linker, SUN Studio C++, Gnat (Ada), Erlang, PC­Lint compiler warnings (configuration of PcLint), Eclipse Buckminster, Oracle Invalids, Doxygen, Robocopy, Perforce, Cobol, PHP, Flex, YUI Compressor, puppet­lint, FxCop, C++ lint, CSSLint, JCReport, and many more... • • • • • • • • • 62
  63. 63. Custom warnings 63
  64. 64. Build labels 64
  65. 65. Groovy Post­build plugin https://wiki.jenkins­ci.org/display/JENKINS/Groovy+Postbuild+Plugin 65
  66. 66. Groovy Post­build plugin 66
  67. 67. Groovy Post­build plugin if(manager.     logContains(".*uses or overrides a deprecated API.*")) {   manager.     addWarningBadge("Thou shalt not use deprecated methods.")   manager.    createSummary("warning.gif").    appendText("<h1>You have been warned!</h1>",       false, false, false, "red")   manager.buildUnstable() } 01. 02. 03. 04. 05. 06. 07. 08. 09. 10. 67
  68. 68. Groovy Post­build plugin 68
  69. 69. Groovy Post­build plugin if("true".equals(   manager.build.buildVariables.get("storeToDB"))) {   manager.addBadge("db_in.gif", "Stored to DB") } 01. 02. 03. 04. 69
  70. 70. Groovy Post­build plugin 70
  71. 71. Groovy Post­build plugin if(manager.build.result.     isBetterOrEqualTo(       hudson.model.Result.UNSTABLE)) {   manager.     addShortText(     "v${manager.build.buildVariables.get('version')}"     ) } 01. 02. 03. 04. 05. 06. 07. 08. 71
  72. 72. Groovy Post­build plugin 72
  73. 73. Groovy Post­build plugin def matcher = manager.getLogMatcher(".*Total time: (.*)$") if(matcher?.matches()) {   manager.     addShortText(      matcher.group(1),       "grey", "white", "0px", "white"     ) } 01. 02. 03. 04. 05. 06. 07. 08. 73
  74. 74. Groovy Post­build plugin 74
  75. 75. Groovy Post­build plugin: icons manager.addBadge("star‐gold.gif", "icon from Jenkins") manager.addBadge("yellow.gif",                   "icon from groovy‐postbuild plugin") manager.addBadge("/images/16x16/yellow.gif",                   "icon from Jenkins") manager.addBadge("/plugin/greenballs/16x16/green.gif",                   "icon from greenballs plugin") 01. 02. 03. 04. 05. 06. 07. 75
  76. 76. ChatOps 76
  77. 77. ChatOps Hipchat Slack Skype Jabber/XMPP etc. • • • • • 77
  78. 78. ChatOps: Slack 78
  79. 79. Scaling Jenkins 79
  80. 80. Single server 80
  81. 81. Master/Slave 81
  82. 82. Labelling 82
  83. 83. Slaves vs. Executors 83
  84. 84. Why scale? 84
  85. 85. Feedback loop 85
  86. 86. Reason 1 86
  87. 87. Monolithic build 87
  88. 88. Monolithic build Time­consuming Resource­consuming Frustration­accumulating • • • 88
  89. 89. Before you can scale... 89
  90. 90. SPLIT!!! 90
  91. 91. Reason 2 91
  92. 92. Too many things to build92
  93. 93. Too many things to build Too many components Too many branches Too many unit/integration tests Too many validation rules • • • • 93
  94. 94. Reason 3 94
  95. 95. Too many things to test 95
  96. 96. Too many test variations Different operating systems Different target platforms Different markets Different customers • • • • 96
  97. 97. Reason 4 97
  98. 98. Lack of resources 98
  99. 99. Reason 5 99
  100. 100. Lack of time! 100
  101. 101. Solutions? 101
  102. 102. Add more hardware! 102
  103. 103. or... 103
  104. 104. Go to the Cloud! 104
  105. 105. Cloud slaves 105
  106. 106. Slave/Executor scaling 106
  107. 107. Jenkins EC2 plugin Allow Jenkins to start slaves on EC2 or Ubuntu Enterprise Cloud (Eucalyptus) on demand, and kill them as they get unused. With this plugin, if Jenkins notices that your build cluster is overloaded, it'll start instances using the EC2 API and automatically connect them as Jenkins slaves. “ 107
  108. 108. Configure access/secret key 108
  109. 109. Configure key pair 109
  110. 110. Configure security group 110
  111. 111. Select machine image Amazon base images AWS market place Create your own • • • 111
  112. 112. Configure EC2 plugin 112
  113. 113. Configure EC2 plugin 113
  114. 114. Configure EC2 plugin 114
  115. 115. Conclusion 115
  116. 116. Recommen­ dations 116
  117. 117. Recommendations: job structure Do not make your build to depend on too many plugins. Do not implement too many build steps inside a job. There should be a possiblity to execute full build job from a command line at any machine. Jenkins is just an executor engine! And a report collector! • • • • • 117
  118. 118. Recommendations: configuration Use provisioning tools to control complex Jenkins installations... ... and to scale them quicker. (Optionally) use containers to isolate build tools from each other. (Optionally) use containers to run acceptance/functional tests of your applications. Use Job DSL to define job templates! • • • • • 118
  119. 119. Recommendations: security Enable HTTPS. Enable Jenkins security. Configure LDAP with users and groups. • • • 119
  120. 120. Recommendations: multi­master Running all your projects in the same Jenkins farm is not always a good idea. If your operations are profiecient in supporting single Jenkins installation, they will be able to setup more. Indepedent projects should leave in isolation. • • • 120
  121. 121. That's it! 121
  122. 122. Jenkins 2.0 Pipeline as code aka  Jenkinsfile Improved UX e.g. recommended plugins Improved UI: job creation, view creation etc. Improved website: better documentation, plugin index etc. Totally backwards compatible! • • • • • 122
  123. 123. Now, that's it for sure! 123
  124. 124. Thank you! 124

×