Container CI & Jenkins Job Builder

Container CI & Jenkins Job Builder

Jenkins study #9
event: http://jenkins.connpass.com/event/35030/
demo: https://github.com/Ladicle/jjb-demo

Talk about Container CI and how to manage Jenkins jobs.

71d7f6cdf5b1934a1b69f0624f5a7523?s=128

Aya (Igarashi) Ozawa

August 10, 2016
Tweet

Transcript

  1. 01 JENKINS STUDY #9 Hello Container CI & JJB Container

    CI & JJB
  2. 2 ABOUT ME Software Engineer AYA IGARASHI NTT Communications @Ladicle

    2
  3. 3 AGENDA INTRODUCTION ContainerCIͷྲྀΕ 01 02 03 04 ARCHITECTURE PROS

    VS CONS JOB MANAGEMENT BEFORE -> AFTER ContainerCIͷ·ͱΊ JOBΛͲͷΑ͏ʹRV, ؅ཧ͢Δ͔? JOB؅ཧΛ࢝ΊΔલͱޙ ͕࣌ؒ͋·Ε͹
 Demo
  4. 4 ARCHITECTURE CONTAINER CI

  5. 5 ContainerCIͷྲྀΕ ARCHITECTURE Push code to GitHub 01 02 03

    04 Build UT & IT jobs Run tests on Containers Notify result to Slack Not plugin Kubernetes :) Parallel execution Web hook plugin
  6. 6 ContainerCIͷ؀ڥߏ੒ ARCHITECTURE VM VM Jenkins OpenStack Kubernetes Docker Registry

    02 CREATE CONTAINERS Container TRIGGER Fixed Components VM VM VM 01 BUILD&PUSH IMAGE
  7. 7 ContainerCIͷ؀ڥߏ੒ ARCHITECTURE VM OpenStack Container 03 PULL IMAGE 04

    EXECUTE TESTS VM Jenkins Kubernetes Docker Registry VM VM VM 02 CREATE CONTAINERS
  8. 8 ContainerCIͷ؀ڥߏ੒ ARCHITECTURE VM OpenStack Container 05 RETURN RESULTS NOTIFY

    VM Jenkins Kubernetes Docker Registry VM VM VM 04 EXECUTE TESTS
  9. 9 Jobߏ੒ (1 BLOCK == 1 JOB) ARCHITECTURE Repository Trigger

    UT Trigger IT Trigger Check syntax Delete containers Build image PullReq Hook Create Containers Delete containers Create Containers Run Scenario Test Run Unit Test Manual Trigger GitHub Event Hook
  10. 10 ContainerCIͷPros/Cons CONCLUSION PROS CONS • ίϯςφ಺Ͱ׬݁͢ΔͷͰࢼݧ؀ڥ͕ԚΕͳ͍ • ඞཁͳ࣌ʹඞཁͳ਺͚ͩࢼݧ؀ڥΛ࡞ΕΔ •

    ಈ࡞֬ೝͨ͠ίϯςφΛͦͷ··ຊ൪؀ڥͰ࢖͑Δ • Πϝʔδͷ࡞੒ͱొ࿥ͷ෼͚ͩɺ͕͔͔࣌ؒΔ • ίϯςφ಺ͷόάղੳʹ͸׳Ε͕ඞཁ • ·ͩރΕ͍ͯͳ͍ͷͰ೔ʑDocker౳ͷόάΛ౿Ή
  11. 11 MANAGEMENT BY JJB શͯΛCLIͰૢ࡞͍ͨ͠ Jenkinsfile΋͍͍͚Ͳ…

  12. 12 Jenkins Job Builderͱ͸? ARCHITECTURE OpenStack Infraͷ1ϓϩδΣΫτɻ YAML·ͨ͸JSONͰJobΛఆٛ/؅ཧͰ͖ΔΑ͏ʹͨ͠΋ͷɻ - job:

    name: 'hoge-trigger' triggers: - timed: '0 9 * * 1-5' scm: - git: url: git@github.com:Ladicle/hoge.git builders: - shell: | echo "Hello world! $VALUE_1” publishers: - email: recipients: 'hello@gmail.com' 01 TRIGGERS CronͷܖػʹϏϧυ͢Δઃఆ 02 SCM GitHubͷࢦఆrepoΛClone͢Δ 02 BUILDERS ຊJOBͰॲཧ͢Δ಺༰ 02 PUBLISHERS ௨஌౳ͷϏϧυޙͷॲཧ ΄΅ɺJENKINSͷJOBઃఆɹɹ ϑΝΠϧͷཁૉͱҰக͍ͯ͠Δ දهΛ֮͑΍͍͢
  13. 13 Jenkins Job Builderͱ͸? ARCHITECTURE - job-template: name: '{repo}-trigger' builders:

    - shell: | echo “Hello {variable1}!“ - project: name: sample default-variable1: 1 repo: - hoge: default-variable1: 3 - piyo - age jobs: - '{repo}-trigger': variable1: '{default-variable1}' ϨϙδτϦ໊͚ͩҟͳΓಉ͡ॲ ཧΛ͢ΔJOBͳͲ΋ɺɹɹɹɹ ม਺Λ࢖͑͹؆୯ʹ࡞ΕΔɻ ୯७ͳYAMLͰ͸ͳ͘ɺม਺ {} ΋࢖͑Δɻ ม਺Λ্ॻ͖ variable1ʹ୅ೖ variable1Λࢀর 01 ࡞੒͞ΕΔJOB໊ hoge-trigger 02 piyo-trigger 03 age-trigger ࣮ߦ͢Δͱ ΋ͪΖΜɺ Pipline΋αϙʔτ
  14. 14 JJBʹΑΔJobͷ؅ཧ ARCHITECTURE YAML XML Jenkins Review Pull & Push

    Convert JJB Apply Before After • ؅ཧ਺ΛݮΒͨ͢Ίಉ͡ॲཧΛ·ͱΊͨ΋ͷͷɺ ৚݅෼ذ͕ෳࡶͰ೉ղ • ೉ղͳͨΊɺଐਓԽ͕ਐΉ • RV͞Εͳ͍··Job͕มߋ͞ΕࣄނΔ • มʹ·ͱΊΔඞཁ͕ͳ͘ͳͬͨͨΊɺɹɹɹɹ Script͕γϯϓϧʹͳͬͨ • γϯϓϧ͔ͭRVͰཧղ͢Δػձ͕૿͑ɺɹɹɹ JobΛߋ৽Ͱ͖Δਓ͕૿͑ͨ • Git(Hub)͕࢖͑Δ
  15. 15 JJB DEMO Using Local Docker https://github.com/Ladicle/jjb-demo

  16. 16 ContainerCI ServiceͱJenkins ADDITIONAL JENKINS CONTAINER CI SERVICE ࢖༻ྔʹԠͯ͡՝ۚ͞ΕΔ Φʔϓϯιʔεʹର͢ΔࢼݧͰ

    ͋Ε͹ແྉͷ΋ͷ͕ଟ͍ αʔόͳͲͷϋʔυ΢ΣΞʹର ͢Δ౤ࢿ͕ෆཁ ΠϯλʔωοτΛܦ༝͢Δ ಛԽͨ͠ػೳΛ࣋ͭ΋ͷ͕ଟ ͘ɺσϑΥϧτͷςϯϓϨʔτ ͕๛෋Ͱॳظֶशίετ͸௿͍ ෳࡶͳ݁߹ࢼݧͳͲɺରԠͰ͖ ͳ͍ࢼݧ΋͋Δ ӡ༻͕ඞཁ ΦϯϓϨϛεͷͨΊɺࣾ಺ωο τϫʔΫʹด͡Δ͜ͱ͕Ͱ͖Δ ΦʔϓϯιʔεͷͨΊɺࠔͬͨ ΒίʔυΛ௥͑Δ JJBΛ࢖͑͹GitͰJob؅ཧͰ͖Δ ͋Δఔ౓ॳظֶशίετ͕͋Δ ཧղޙ͸ͲΜͳࢼݧʹ΋ॊೈʹ ରԠ͠΍͍͢ ༻్ʹԠͯ͡ ࢖͍෼͚
  17. 17 Upgrade container Jenkins from v1.642 to v2.7 ADDITIONAL STEP

    02 STEP 03 STEP 04 STEP 01 BACKUP $JENKINS_HOME Λ·Δͬͱอଘ CHANGE IMAGE TAG TAGΛ2.7ʹมߋ PROS VS CONS ݱߦίϯςφఀࢭ PROS VS CONS ίϯςφΛ࠶ىಈ
  18. Thanks for watching! See You Next Time 18 @ladicle