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

JenkinsのJobを CronJobに移した話 /The story of moving Jenkins Job to CronJob

JenkinsのJobを CronJobに移した話 /The story of moving Jenkins Job to CronJob

2020/07/17 社内LT会で発表

9a71d9081335ef7d5ecfa86155c949af?s=128

yutachaos

July 17, 2020
Tweet

Transcript

  1. &/(-*4)43&άϧʔϓ໦ଜ༐ଠ +FOLJOTͷ+PCΛ $SPO+PCʹ Ұ෦ Ҡͨ͠࿩ 2VJQQFSࣾ಺-5ձ

  2. 8IP*BN w ໦ଜ༐ଠ w &/(-*4)43&άϧʔϓॴଐ w झຯ w Իָɺָثԋ૗ w

    ञ ࠷ۙ͸ΫϥϑτϏʔϧ޷͖Ͱ͢
  3. ࠓ೔ͷΞδΣϯμ w +FOLJOTʹ͍ͭͯ w +FOLJOT͓͡͞Μ໰୊ʹ͍ͭͯ w $SPO+PC w &/(-*4)ͷ+PCج൫ͷߏ੒

  4. ˞ w ࠓճͷࢿྉͰ͸+FOLJOTʹରͯ͠ݫ͠໨ͳҙݟΛॻ͖·͠ ͕ͨɺ๻͸+FOLJOT͕େ޷͖Ͱ͢ɻ

  5. w ݩʑ͸)VETPOͱ͍͏1SPKFDU໊Ͱ4VO .JDSPTZTUFNTͰ։ൃ͞Ε͍ͯͨ$* $%πʔϧɻ w 4FSWMFU$POUBJOFS 5PNDBUͰ࡞ΒΕͨ +BWBͷ8FCΞϓϦέʔγϣϯ w (JU

    47/ .FSDVSJBM $7/ͳͲ༷ʑͳό ʔδϣϯ؅ཧπʔϧʹରԠ w େྔͷQMVHJO͕͋Γɺ+6OJUͷΧόϨ οδΛදࣔͨ͠Γɺ+FOLJOTpMFͰ QJQFMJOFΛએݴతʹॻ͍ͨΓɺTIFMMΛ ୯७ʹ࣮ߦͨ͠ΓͳͲଟछଟ༷ͳΦϖ Ϩʔγϣϯʹར༻ग़དྷΔɻ +FOLJOT
  6. +FOLJOT͓͡͞Μ໰୊ʹ͍ͭͯ w +FOLJOT͸ϝϦοτɾσϝϦοτ͸ଘࡏ͢Δ͕ɺඇৗʹศར͔ͭڧྗͳϓϩμ ΫτͰҰՈʹҰ୆+FOLJOTɻ w ͔͠͠ɺศརͳ+FOLJOTʹґଘ͍ͯ͘͠ͱ+FOLJOTͷӡ༻ࣗମʹଐਓੑ͕ൃੜ ࢝͠Ίɺൿ఻ͷ+FOLJOTʹͳ͍͖ͬͯɺ͍͔ͭ͠બ͹Ε͠ऀ͔͠+FOLJOTʹ৮ Εͳ͘ͳ͍ͬͯ͘+FOLJOT͓͡͞Μͷ஀ੜͰ͋Δɻ

  7. +FOLJOT͓͡͞Μ͸ͳͥ஀ੜ͢Δͷ͔ɻ w +FOLJOTͷϝϦοτ w ઃఆͷ؅ཧ໰୊ w ઃఆͷίʔυԽ໰୊ w +FOLJOTࣗମͷWFSTJPO؅ཧ໰୊ w

    ਆ+FOLJOT໰୊
  8. +FOLJOTͷϝϦοτ w JOTUBMM͕؆୯ɺ+FOLJOTࣗମ͸ϞϊϦγοΫͳ+BWB"QQMJDBUJPOͷͨΊɺ+BS ͕͋Ε͹؆୯ʹىಈ͢Δ͜ͱ͕ग़དྷΔ w ίϛϡχςΟϕʔεͰ։ൃ͞Ε͍ͯΔ๛෋ͳ1MVHJO͕͋ΔͨΊɺඪ४ʹͳ͍ػ ೳͰ΋1MVHJOΛ࢖͏ͱग़དྷΔ͜ͱ͕ଟ͍ w (6*ϕʔεͰ+PCͷ࡞੒ɺ࠶࣮ߦɺϩάͷ֬ೝͳͲ͕ग़དྷɺ؆୯ͳӡ༻πʔϧ ͳͲ͸؅ཧը໘Λ࡞Βͣʹ࡞੒͢Δ͜ͱ͕ग़དྷΔ

  9. ઃఆͷ؅ཧ໰୊ w +FOLJOT͸جຊతʹ(6*Ͱઃఆ΍+PCΛߏங͢Δ͜ͱ͕ଟ͍ ͦͯ͠ؾܰʹͰ͖ ͯ͠·͏ ͨΊɺҰ౓յΕͯ͠·ͬͨઃఆΛ࠶ઃఆ͕ࠔ೉ʹͳΔɻ·ͨ +FOLJOTQMVHJOΛར༻ͨ͠+PCΛઃఆ͢Δ৔߹ɺ+FOLJOTຊମʹQMVHJOΛೖΕ ͯɺઃఆΛ͢Δඞཁ͕͋ΔͨΊߋʹઃఆ͸ࠔ೉ʹͳ͍ͬͯ͘ɻ

  10. ઃఆͷίʔυԽ໰୊ w +FOLJOTͷຊମͷઃఆΛ؅ཧ͢ΔͨΊʹ+FOLJOT$POpHVSBUJPOBT $PEF IUUQTXXXKFOLJOTJPQSPKFDUTKDBTD ΍QJQFMJOFͷ+PCΛ؅ཧ͢ ΔͨΊͷ+FOLJOTpMFͱ͍͏΋ͷ͕͋Γ(SPPCZ%4-Ͱ+PCͷ಺༰Λهड़͢Δ ͜ͱ΋ग़དྷΔ͕ɺ+FOLJOT$POpHVSBUJPOBT$PEFʹؔͯ͠΋ɺ+FOLJOTpMF ʹؔͯ͠΋ɺ(6*͔Βొ࿥ɾ൓өΛͤ͞Δ࡞ۀ͕ඞཁʹͳΔɻ+PCͷ಺༰͸HJU Ͱ؅ཧ͍ͯ͠Δ͕ɺ൓ө͕खಈ΋͘͠͸TDSJQUͰ൓ө͢ΔͳͲͷ੔උ͕ඞཁʹ

    ͳΔɻ
  11. +FOLJOTࣗମͷWFSTJPO؅ཧ໰୊ w +FOLJOTࣗମΛ͙͢ʹ࡞Γ௚ͤΔͱ͍͏ঢ়ଶͰ؅ཧ͢Δͷ͸ɺݱ࣌఺Ͱ͸·ͩ ·ͩରԠ͢Δ΂͖఺͕ଟ͘େม͕ͩɺ+FOLJOTࣗମ͕ݹ͍ঢ়ଶɺ1MVHJOΛ৽͠ ͘͢Δʹରͯ͠ɺ+FOLJOTຊମ΍1MVHJOͷVQEBUF͸ඞཁʹͳͬͯ͘Δɻͳͷ ͰؾܰʹVQEBUFΛ͍͕ͨ͠ɺલड़ͷਆ+FOLJOT໰୊ͰɺVQEBUFʹࣦഊͨ͠৔ ߹ɺαʔϏεӨڹ͕ൃੜͯ͘͠ΔϨϕϧʹͳͬͯ͘Δͱ༻ҙʹVQEBUF͕ग़དྷ ͳ͘ͳ͍ͬͯ͘ͱ͍͏໰୊͕ൃੜͨ͠Γɺͦ΋ͦ΋+PC͸͋Δ͕৽͍͠΋ͷΛ ૿΍͢͜ͱ͸ͳ͔ͬͨɺ+FOLJOTࣗମ͕QMVHJO΍ཤྺͳͲΛϑΝΠϧγεςϜ ʹอଘ͢ΔTUBUFGVMͳBQQMJDBUJPOͷͨΊɺVQEBUF΋EPXOHSBEF΋ग़དྷͳ͍

    ͱ͍͏ঢ়گʹؕΓɺ์ஔ͞ΕΔ͜ͱͳͲ͕ى͖Δɻ
  12. ਆ+FOLJOT໰୊ w +FOLJOT͸CVJME΋UFTU΋௨஌΍σʔλऩूͳͲͷӡ༻+PC΍ఆظ+PCͳͲԿͰ ΋࣮ߦ͢Δ͜ͱ͕ग़དྷΔͷͰɺҰͭͷ+FOLJOTʹେྔͷ+PC͕ू·ͬͯ͠· ͍ɺ+FOLJOT͕ࢭ·ͬͨͱ͖αʔϏεఀࢭϨϕϧͷӨڹൣғʹͳͬͯ͠· ͏ɻ w ·ͨ+FOLJOTࣗମʹ৭ʑͳϑϩʔ͕ߦ͑ΔΑ͏ʹ͢ΔͨΊʹɺ%#ʹ௚઀ΞΫ ηεग़དྷΔɺڧ͍"84ͷݖݶΛ࣋ͨͤΔͳͲΛͯ͠͠·͏ͱɺ+FOLJOTࣗମ ʹूதͯ͠͠·͍ɺ+FOLJOTࣗମ͕ηΩϡϦςΟϦεΫʹͳΔͱಉ࣌ʹɺΦϖ

    ϨʔγϣϯϛεͰॏେͳഁյΛىͤ͜ΔΑ͏ʹͳͬͯ͠·͏ɻ
  13. $SPO+PC w ,VCFSOFUFTඪ४Ͱ༻ҙ͞Ε͍ͯΔ+PCͷఆظ࣮ߦʹରԠ͍ͯ͠ΔSFTPVSDFT w $SPOUBCܗࣜͰઃఆΛهड़͕ग़དྷΔ w 8PSLqPXʹ͸ඇରԠ

  14. $SPO+PCͷϝϦοτɾσϝϦοτ w ϝϦοτ w ઃఆΛZBNMͰهड़ͯ͠ίʔυ؅ཧ͕ग़དྷΔɻ w $POUBJOFSϕʔεͰͷ࣮ߦ͕Մೳ w LTͷΤίγεςϜʹͷΕΔ w

    σϝϦοτ w (6*͔Β͸ઃఆग़དྷͣɺίʔυ؅ཧ͢Δඞཁ͕͋Δ w +FOLJOTͱൺ΂Δͱ࢖͍΍͍͢(6*͕ͳ͍ w TMBDL௨஌ͳͲͷػೳΛࣗ෼Ͱઃఆ͠ͳ͍ͱߦ͚ͳ͍
  15. +PCج൫ͷߏ੒ʹ͍ͭͯ w .BOJGFTU w ,VTUPNJ[F w "SHP$% w (JUIVC w

    $MVTUFS w &,4 w 4QPUPDFBO w 4MBDL௨஌ɾ؂ࢹ w LVCFKPCOPUJpFS w %BUBEPH
  16. .BOJGFTUͷ؅ཧ w LVTUPNJ[FΛར༻ w ֤+PCຖʹσΟϨΫτϦΛ࡞Γɺ PWFSMBZͰ؀ڥࠩ෼Λٵऩ σΟϨΫτϦߏ੒ྫ KPCT ᵓᴷᴷ3&"%.&NE ᵋᴷᴷIPHFKPC

    ᵓᴷᴷBSHPDE@BQQMJDBUJPO ᵓᴷᴷCBTF ᴹᴹᵓᴷᴷBQQMJDBUJPOZBNM ᴹᴹᵋᴷᴷLVTUPNJ[BUJPOZBNM ᴹᵋᴷᴷPWFSMBZT ᴹᵓᴷᴷQSPEVDUJPO ᴹᴹᵓᴷᴷBQQMJDBUJPOZBNM ᴹᴹᵋᴷᴷLVTUPNJ[BUJPOZBNM ᴹᵋᴷᴷTUBHJOH ᴹᵓᴷᴷBQQMJDBUJPOZBNM ᴹᵋᴷᴷLVTUPNJ[BUJPOZBNM ᵋᴷᴷKPC ᵓᴷᴷCBTF ᴹᵓᴷᴷDSPOKPCZBNM ᴹᵋᴷᴷLVTUPNJ[BUJPOZBNM ᵋᴷᴷPWFSMBZT ᵓᴷᴷQSPEVDUJPO ᴹᵓᴷᴷDSPOKPCZBNM ᴹᵋᴷᴷLVTUPNJ[BUJPOZBNM ᵋᴷᴷTUBHJOH ᵓᴷᴷDSPOKPCZBNM ᵋᴷᴷLVTUPNJ[BUJPOZBNM
  17. .BOJGFTUͷ൓ө

  18. .BOJGFTUͷ൓ө w ։ൃऀ͕(JUIVCʹ13Λग़͢ w $JSDMF$*ͰUFTU͕ಈ͘ w 13͕NFSHF͞ΕΔ w NBTUFS͕ߋ৽͞ΕΔ w

    "SHP$%͕NBTUFSͷࠩ෼Λݕ஌ͨ͠ΒɺLVCFSOFUFTDMVTUFSʹ൓ө͢Δ
  19. $MVTUFSߏ੒

  20. $MVTUFS w &,4Λར༻ w /PEFͷTDBMJOHʹؔͯ͠͸TQPUͷPDFBO IUUQTXXXYMTPGUDPNKQ QSPEVDUTTQPUPDFBOIUNM Λ࢖ͬͯ؅ཧ͍ͯ͠Δɻ w ؅ཧ͸DMVTUFS࡞੒࣌ʹOPEFΛTQPUͷ؅ཧ͢ΔͱOPEFΛࣗಈͰ؅ཧͯ͘͠Ε

    ΔɺTQPUJOTUBODFΛར༻͢Δ͜ͱ΋Մೳɻ w TUBHJOHͰ͸TQPUJOTUBODFΛར༻ɺQSPEVDUJPOͰ͸POEFNBOEJOTUBODF Λར༻
  21. 4MBDL௨஌ +FOLJOT w ݩʑ+FOLJOTͰ͸+FOLJOTͷTMBDLQMVHJOͱ%BUB%PHͷ4FSWJDF$IFDLར༻͠ ͯɺ+PCͷ։࢝ɺऴྃɺࣦഊͳͲΛTMBDLʹ௨஌͢ΔΑ͏ʹ͍ͯͨ͠ɻ

  22. 4MBDL௨஌ $SPO+PC w LVCFKPCOPUJpFS w IUUQTHJUIVCDPNZVUBDIBPTLVCFKPCOPUJpFS w +PCͷॲཧʹTMBDL΍%BUBEPHͷॲཧΛ૊ΈࠐΉͷ͸ख͕͔͔ΔͷͰࣗ࡞ͨ͠ w +PCͷFWFOUΛ؂ࢹͯ͠ɺ+PCͷ։࢝ɺऴྃɺࣦഊͳͲͷ৘ใΛTMBDL௨஌

    w 1PEͷϩά΋TMBDLʹఴ෇ w 0QUJPOͱͯ͠%BUBEPHͷ4FSWJDF$IFDLΛૹΔػೳ΋࣮૷
  23. 4MBDL௨஌ $SPO+PC

  24. ·ͱΊ w ྑ͔ͬͨ͜ͱ w +FOLJOT͔Β͔ͳΓͷ+PC͕ݮͬͨͷͰɺ+FOLJOT͕ࢮΜͩͱ͖ͷӨڹൣғ ͕͔ͳΓݮͬͨɻ࣮ͦͯ͠ࡍઌ݄+FOLJOT͕ಥવࢮΜͩ ƅ㱼ƅ ŋ㲎 w ࠓ·Ͱ؀ڥʹΑͬͯઃఆ͞Ε͍ͯͳ͔ͬͨ+PCͳͲ͕͋ͬͨͷ͕ແ͘ͳΓɺ

    TUBHJOH؀ڥͰ΋+PC͕ͪΌΜͱ੔උ͞Εͨɻ w 13ϕʔεͰҾ਺΍ઃఆͷมߋΛݟΔ͜ͱ͕ग़དྷΔΑ͏ʹͳͬͨͷͱɺ NBOJGFTUࣗମʹςετΛ͔͚Δ͜ͱ͕ग़དྷΔΑ͏ʹͳͬͨɻ
  25. ࠓޙͷ՝୊ w ࠶࣮ߦͷ࢓૊Έ w (6*͔Β΋ҰԠग़དྷΔ͕खॱ͕൥ࡶͳͷͰࠓͷ$6*Ͱͷ࠶࣮ߦΛ͍ͯ͠Δ w LVCFKPCOPUJpFSͷվम w Ͳͷ$POUBJOFSͷϩάΛग़͔͢ͳͲɺෳ਺1PEͰͷಈ࡞ʹରԠ͍ͯ͠ͳ͍ɻ w

    LVCFKPCOPUJpFSࣗମ͕Ҏ্ʹͳͬͨͱ͖ͷಈ࡞ͷߟྀΛ͍ͯ͠ͳ͍ɻ w 0O%FNBOE+PCΛͲ͏͢Δ͔ w $SPO+PC͸جຊతʹఆظ+PCͷͨΊͷ΋ͷͳͷͰɺӡ༻ͳͲͰखಈʹಈ͔͢+PCʹؔͯ͠ɺ·ͩ+FOLJOTʹ ࢒͍ͯ͠ΔͷΛͲ͏͢Δ͔ w 8PSLqPX w ݱࡏXPSLqPXΛ૊ΜͰ͍Δ+PC͕΄΅ແ͍ͨΊɺ΄ͱΜͲͷ+PCΛҠߦग़དྷ͕ͨɺXPSLqPX͕ඞཁʹͳͬ ͨͱ͖ʹͲ͏͢Δ͔ʁBSHPXPSLqPXT IUUQTHJUIVCDPNBSHPQSPKBSHP Λ࢖͏ʁ
  26. ͋Γ͕ͱ͏͍͟͝·ͨ͠