Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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.

Aya (Igarashi) Ozawa

August 10, 2016
Tweet

More Decks by Aya (Igarashi) Ozawa

Other Decks in Technology

Transcript

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

    VS CONS JOB MANAGEMENT BEFORE -> AFTER ContainerCIͷ·ͱΊ JOBΛͲͷΑ͏ʹRV, ؅ཧ͢Δ͔? JOB؅ཧΛ࢝ΊΔલͱޙ ͕࣌ؒ͋·Ε͹
 Demo
  2. 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
  3. 6 ContainerCIͷ؀ڥߏ੒ ARCHITECTURE VM VM Jenkins OpenStack Kubernetes Docker Registry

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

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

    VM Jenkins Kubernetes Docker Registry VM VM VM 04 EXECUTE TESTS
  6. 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
  7. 10 ContainerCIͷPros/Cons CONCLUSION PROS CONS • ίϯςφ಺Ͱ׬݁͢ΔͷͰࢼݧ؀ڥ͕ԚΕͳ͍ • ඞཁͳ࣌ʹඞཁͳ਺͚ͩࢼݧ؀ڥΛ࡞ΕΔ •

    ಈ࡞֬ೝͨ͠ίϯςφΛͦͷ··ຊ൪؀ڥͰ࢖͑Δ • Πϝʔδͷ࡞੒ͱొ࿥ͷ෼͚ͩɺ͕͔͔࣌ؒΔ • ίϯςφ಺ͷόάղੳʹ͸׳Ε͕ඞཁ • ·ͩރΕ͍ͯͳ͍ͷͰ೔ʑDocker౳ͷόάΛ౿Ή
  8. 12 Jenkins Job Builderͱ͸? ARCHITECTURE OpenStack Infraͷ1ϓϩδΣΫτɻ YAML·ͨ͸JSONͰJobΛఆٛ/؅ཧͰ͖ΔΑ͏ʹͨ͠΋ͷɻ - job:

    name: 'hoge-trigger' triggers: - timed: '0 9 * * 1-5' scm: - git: url: [email protected]:Ladicle/hoge.git builders: - shell: | echo "Hello world! $VALUE_1” publishers: - email: recipients: '[email protected]' 01 TRIGGERS CronͷܖػʹϏϧυ͢Δઃఆ 02 SCM GitHubͷࢦఆrepoΛClone͢Δ 02 BUILDERS ຊJOBͰॲཧ͢Δ಺༰ 02 PUBLISHERS ௨஌౳ͷϏϧυޙͷॲཧ ΄΅ɺJENKINSͷJOBઃఆɹɹ ϑΝΠϧͷཁૉͱҰக͍ͯ͠Δ දهΛ֮͑΍͍͢
  9. 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΋αϙʔτ
  10. 14 JJBʹΑΔJobͷ؅ཧ ARCHITECTURE YAML XML Jenkins Review Pull & Push

    Convert JJB Apply Before After • ؅ཧ਺ΛݮΒͨ͢Ίಉ͡ॲཧΛ·ͱΊͨ΋ͷͷɺ ৚݅෼ذ͕ෳࡶͰ೉ղ • ೉ղͳͨΊɺଐਓԽ͕ਐΉ • RV͞Εͳ͍··Job͕มߋ͞ΕࣄނΔ • มʹ·ͱΊΔඞཁ͕ͳ͘ͳͬͨͨΊɺɹɹɹɹ Script͕γϯϓϧʹͳͬͨ • γϯϓϧ͔ͭRVͰཧղ͢Δػձ͕૿͑ɺɹɹɹ JobΛߋ৽Ͱ͖Δਓ͕૿͑ͨ • Git(Hub)͕࢖͑Δ
  11. 16 ContainerCI ServiceͱJenkins ADDITIONAL JENKINS CONTAINER CI SERVICE ࢖༻ྔʹԠͯ͡՝ۚ͞ΕΔ Φʔϓϯιʔεʹର͢ΔࢼݧͰ

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