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

開発者(個人)のためのJenkins 運用編

Yasuhiroki
November 08, 2017

開発者(個人)のためのJenkins 運用編

第11回 Jenkins勉強会 LT

Yasuhiroki

November 08, 2017
Tweet

More Decks by Yasuhiroki

Other Decks in Technology

Transcript

  1. DockerͰJenkinsΛىಈ͢Δ • Docker • https://hub.docker.com/_/jenkins/ Ͱ͸ͳ͘ • https://hub.docker.com/r/jenkinsci/jenkins/ Ͱ΋ͳ͘ •

    https://hub.docker.com/r/jenkins/jenkins/ ͚ͩͲ • https://store.docker.com/images/jenkins ΋͋Δ
  2. ΧελϚΠζ͸DockerfileͰ • Dockerfile • ࢲͷͨΊͷJenkinsͷॳظߏங • ࣗ෼༻ͷ Docker ΠϝʔδΛ DockerHub

    ʹ push ͯ͠΋ྑ͍ • ࣗ෼ͷࣥࣄ͕ଞॴͰಇ͍ͯ΋ࣧౄ͠ͳ͍ਓʹݶΔ • ͋Β͔͡Ί༻ҙ͞Ε͍ͯΔػೳΛ࢖͑͹ɺ
 DockerΠϝʔδΛ༻ҙ͠ͳͯ͘΋͋Δఔ౓ಈతʹߏஙͰ͖Δ
  3. GitHub Organization Plugin • Multibranch Pipeline ͷ GitHub ಛԽ൛ •

    ࣗ෼ͷΞΧ΢ϯτΛࢦఆ͢Δ͚ͩͰɺJenkinsfile Λ࣋ͭ ϦϙδτϦΛݕग़ͯ͠উखʹϏϧυͯ͘͠ΕΔ • ࠓճ͸ https://github.com/yasuhiroki/myJenkinsfile ͚ͩ Λݕग़͢ΔΑ͏ʹઃఆ
  4. git worktree ίϚϯυ • δϣϒ͝ͱʹ͍͍ͪͪ checkout ͢Δͷ͸໘౗ͳͷͰɺ
 git worktree ίϚϯυΛར༻͢Δ

    • git worktree add jobs/today-is jobs/today-is ͱ͢Δͱɺ
 jobs/today-is σΟϨΫτϦʹ jobs/today-is ϒϥϯν͕ νΣοΫΞ΢τ͞ΕΔ • ϒϥϯνͷ਺͚ͩσΟϨΫτϦΛ࡞ͬͯ checkout ͢Ε͹ɺ
 δϣϒͷઃఆ͕ू·ͬͨ jobs σΟϨΫτϦͷͰ͖͕͋Γ
  5. Docker Pipeline plugin • JenkinsfileͰϏϧυΛ࣮ߦ͍ͨ͠ docker image Λࢦఆ͢ Δ •

    Jenkinsίϯςφͱಉ͡ docker.sock Λ࢖͏Α͏ઃఆ͢Ε ͹ɺJenkinsίϯςφࣗମ΋৮ΕΔ • ༡ͼϙΠϯτ • ྫɿࣥࣄةػҰ൅ήʔϜ
  6. jenkinsci/jnlp-slave • *.override ͷػೳΛ࢖ͬͯɺࣄલʹϊʔυͷ৘ใΛ Jenkinsʹ༻ҙ͓ͯ͘͠ͱॳظߏஙΛ΄΅ࣗಈԽͰ͖Δ • secret τʔΫϯ͸Ұ౓࡞ΒΕͨΒ JENKINS_HOME ҎԼ

    Λ࡞Γ௚͞ͳ͍ݶΓಉ͡ͳͷͰࣗಈԽͰ͖Δ • ॳճ͚ͩ͸खಈͰొ࿥͕ඞཁ • groovy ͰΰϦΰϦ΍Ε͹׬શࣗಈԽͰ͖Δؾ͕͢Δ
  7. FIN