Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜

6.852 visualizaciones

Publicado el

https://forkwell.connpass.com/event/51332/
Productivity Engineering − Forkwell Meetup #4 の発表資料です。
Jenkins 2.0の最新情報について話しました。

Publicado en: Ingeniería
  • Inicia sesión para ver los comentarios

Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜

  1. 1. Jenkins 2.0 Make Jenkins Great Again! Miyata Jumpei (@miyajan) Mar 18, 2017 Productivity Engineering - Forkwell Meetup #4
  2. 2. ⾃⼰紹介 • 宮⽥ 淳平 (@miyajan) • Cybozu • ⽣産性向上チーム • Jenkinsおじさん
  3. 3. Jenkins 2.0!
  4. 4. Background
  5. 5. History • 2005 Hudson 1.0 • 2011 Forked to Jenkins • 2016/04 Jenkins 2.0
  6. 6. Jenkins 1.0 • 10 years • 100K active users • 1000 plugins
  7. 7. • CI • • /UI • Jenkins • CI/CD • UX
  8. 8. https://jenkins.io/blog/2016/04/26/jenkins-20-is-here/
  9. 9. Jenkins 2.0 • 10 • • 1.0 • Deprecated: Jenkins
  10. 10. $ docker run -p 8080:8080 jenkins:2.32.3 # http://localhost:8080 Try Jenkins 2.0
  11. 11. Jenkins 2.0 Features
  12. 12. Suggested Plugins
  13. 13. • • • … Jenkins 1.0
  14. 14. Suggested Plugins • • • Pipeline, Git, Mail, Credential Binding, etc. Jenkins 2.0
  15. 15. Pipeline
  16. 16. • • Build Pipeline Plugin • Delivery Pipeline Plugin • • • Jenkins 1.0
  17. 17. Pipeline Plugin • DSL( ) • 1 • • master Jenkins 2.0
  18. 18. Pipeline DSL
  19. 19. GUI • • • JobConfigHistory Plugin … Jenkins 1.0
  20. 20. 300 input
  21. 21. Pipeline as Code • DSL(Groovy) • • • Jenkins 2.0
  22. 22. • • • https://github.com/jenkinsci/pipeline- plugin/blob/master/COMPATIBILITY.md • • https://github.com/jenkinsci/pipeline- plugin/blob/master/DEVGUIDE.md Jenkins 2.0
  23. 23. Scripted Pipeline & Declarative Pipeline
  24. 24. Scripted Pipeline • Pipeline • • • try/catch… Jenkins 2.0
  25. 25. node(‘has-docker’) { try { checkout scm stage(‘Build’) { sh ‘mvn clean install’ } stage(‘Archive’) { ( ) } if (currentBuild.result == 'SUCCESS') { mail to:"me@example.com", subject:"SUCCESS", body: "passed." } } catch (exc) { mail to:"me@example.com", subject:"FAILURE", body: "failed." } finally { deleteDir() } }
  26. 26. Declarative Pipeline • • • Lint Jenkins 2.0
  27. 27. pipeline { agent label:’has-docker’, dockerfile: true stages { stage("Build") { steps { sh 'mvn clean install' } } stage("Archive"){ ( ) } } post { always { deleteDir() } success { mail to:"me@example.com", subject:"SUCCESS", body: "passed." } failure { mail to:"me@example.com", subject:"FAILURE", body: "failed." } } }
  28. 28. Lint • • curl ssh lint • https://github.com/jenkinsci/pipeline-model- definition-plugin/wiki/Validating-(or-linting)-a- Declarative-Jenkinsfile-from-the-command-line • npm • https://www.npmjs.com/package/jflint
  29. 29. Lint from CLI • curl ssh lint • https://github.com/jenkinsci/pipeline-model- definition-plugin/wiki/Validating-(or-linting)-a- Declarative-Jenkinsfile-from-the-command-line • npm • https://www.npmjs.com/package/jflint
  30. 30. • Declarative Pipeline • “script” Scripted Pipeline
  31. 31. Declarative Pipeline Examples
  32. 32. Build in Container // simple agent { docker “ubuntu:16.04” } // specify label & args agent { docker { image “ubuntu:16.04” label “docker-nodes” args “-v /tmp:/tmp -p 8000:8000” } }
  33. 33. Credentials
  34. 34. Credentials environment { // type: secret text // SECRET_TEXT is defined SECRET_TEXT = credentials(‘SECRET_TEXT') // type: username and password // SECRET_AUTH_USR and SECRET_AUTH_PSW are defined SECRET_AUTH = credentials('SECRET_AUTH') }
  35. 35. Options pipeline { options { // 7 buildDiscarder(logRotator(daysToKeepStr: '7')) } }
  36. 36. Triggers pipeline { triggers { cron('* * * * *') } }
  37. 37. Parallel stage("Commit") { steps { parallel( unitTest: { … }, staticAnalysis: { … }, package: { … } ) } }
  38. 38. Conditions stage("Production") { when { branch "master" } steps { // deploy to production } }
  39. 39. Stash stage("Archive") { agent { docker “java:8” } steps { sh “gradle jar” stash name: “jar”, includes: “build/libs/*.jar” } } stage(“Deployment”) { agent { docker … } steps { unstash “jar” // jar } }
  40. 40. User Input stage("Production") { steps { input “Ready to deploy?” } }
  41. 41. Syntax • https://github.com/jenkinsci/pipeline-model- definition-plugin/wiki/Syntax-Reference • https://jenkins.io/doc/book/pipeline/syntax/
  42. 42. Shared Libraries
  43. 43. • • … • subtree or submodule…? Jenkins 1.0
  44. 44. Shared Libraries • GitHub • Groovy • https://jenkins.io/doc/book/pipeline/shared- libraries/ Jenkins 2.0
  45. 45. Example: without Library pipeline { … post { failure { // echo ‘failure!’ with red color ansiColor('xterm') { echo '033[0;31mFailure!033[0m' } } } … }
  46. 46. vars/echoErr.groovy #!/usr/bin/env groovy def call(String text) { ansiColor('xterm') { echo “033[0;31m${text}033[0m" } }
  47. 47. (repository root) +- vars - +- echoErr.groovy
  48. 48. Example: with Library @Library('miyata-shared-libraries') _ pipeline { … post { failure { echoErr ‘Failure!’ } } … }
  49. 49. • DRY • • @Library('my-shared-library@1.0') _ •
  50. 50. GitHub
  51. 51. • push • commit status
  52. 52. GitHub Plugin • • commit status pending 
 commit status … • Jenkins 1.0
  53. 53. GitHub Organization Folder • Organization • Jenkinsfile Multibranch Pipeline GitHub Jenkins 2.0
  54. 54. Multibranch Pipeline • • Jenkinsfile • Jenkins 2.0
  55. 55. • 1
  56. 56. • • Webhook • BitBucket
  57. 57. Blue Ocean
  58. 58. Classic Jenkins UI • UX Jenkins 1.0
  59. 59. Blue Ocean • UX • • RC • • Blue Ocean Plugin Jenkins 2.0
  60. 60. Pipeline Editor
  61. 61. Pipeline Editor • Blue Ocean • Jenkinsfile GUI Jenkins 2.0
  62. 62. stage • • Enterprise • Groovy … • JENKINS-33846
  63. 63. • LTS … • LTS(stable) •
  64. 64. GUI • • • init.groovy.d ... • • https://github.com/jenkinsci/system-config-dsl- plugin
  65. 65. Best Practices • Declarative Pipeline • GitHub Organization Folder • Blue Ocean
  66. 66. References • https://jenkins.io/doc/ • https://jenkins.io/node/ • https://www.cloudbees.com/juc/agenda
  67. 67. Cybozu Meetup 1 2 : https://cybozu.connpass.com/event/52668/

×