Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
開発者(個人)のためのJenkins 運用編
Search
Yasuhiroki
November 08, 2017
Technology
0
2.2k
開発者(個人)のためのJenkins 運用編
第11回 Jenkins勉強会 LT
Yasuhiroki
November 08, 2017
Tweet
Share
More Decks by Yasuhiroki
See All by Yasuhiroki
自分に勉強させるには
yasuhiroki
1
380
Android Studio `Command+Shift+A`
yasuhiroki
0
310
シェルスクリプトをサーバーレスで cron したい
yasuhiroki
1
760
rails new コマンド
yasuhiroki
1
700
自動化を習慣化する
yasuhiroki
2
14k
GitHub Actions Parallel Testing
yasuhiroki
1
1.2k
circleci.vim
yasuhiroki
0
1.5k
ベンチャー企業がCircleCIを選んだ理由と活用方法
yasuhiroki
1
760
Rubyの正規表現を調べてみた
yasuhiroki
0
780
Other Decks in Technology
See All in Technology
Lexical Analysis
shigashiyama
1
150
ドメイン名の終活について - JPAAWG 7th -
mikit
33
20k
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
5
590
AGIについてChatGPTに聞いてみた
blueb
0
130
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
470
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
3
190
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
[FOSS4G 2019 Niigata] AIによる効率的危険斜面抽出システムの開発について
nssv
0
310
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
Featured
See All Featured
Optimizing for Happiness
mojombo
376
70k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Done Done
chrislema
181
16k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
860
Statistics for Hackers
jakevdp
796
220k
Docker and Python
trallard
40
3.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Building an army of robots
kneath
302
43k
Making Projects Easy
brettharned
115
5.9k
Building Your Own Lightsaber
phodgson
103
6.1k
Transcript
։ൃऀ(ݸਓ)ͷͨΊͷ Jenkins ӡ༻ฤ @yasuhiroki
@yasuhiroki
https://certificates.cloudbees.com/10203903
։ൃऀ(ݸਓ)ͷͨΊͷJenkins
ࢲͷࢲʹΑΔࢲͷͨΊͷJenkins • ผʹࣗͰͬͯྑ͍Μ͚ͩͲɺ ΘΓʹͬͯ͘ΕΔͳΒॿ͔Δ࡞ۀ • ۀͱͯࣗ͠ಈԽ͢Δ΄ͲͰͳ͍͚Ͳɺ ࣗಈԽͤͣʹ͍ΒΕͳ͔ͬͨ࡞ۀ • ༡ͼ
ͤͳੜ׆ ࠓૉ͔ɺφϕΞπ͔Λڭ͑ͯ͘ΕΔࣥࣄ
ࣥࣄޏ༻ܭը
ࣥࣄ͍ࣺͯ
ඞཁͳ࣌ʹޏ͍ ඞཁͷͳ͍࣌ղޏ͢Δ
Jenkinsͷߏங
ࢲͷͨΊͷJenkins͔ͩΒ ࢲͷ͖ͳΑ͏ʹߏங͢Δ
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 ͋Δ
JenkinsͷߏஙGitHubͰཧ • docker-compose • docker-compose.yml Λ GitHub Ͱཧ
ΧελϚΠζDockerfileͰ • Dockerfile • ࢲͷͨΊͷJenkinsͷॳظߏங • ࣗ༻ͷ Docker ΠϝʔδΛ DockerHub
ʹ push ͯ͠ྑ͍ • ࣗͷࣥࣄ͕ଞॴͰಇ͍ͯࣧౄ͠ͳ͍ਓʹݶΔ • ͋Β͔͡Ί༻ҙ͞Ε͍ͯΔػೳΛ͑ɺ DockerΠϝʔδΛ༻ҙ͠ͳͯ͋͘ΔఔಈతʹߏஙͰ͖Δ
*.override • ެࣜJenkins Docker ͷػೳ • config.xml.override ͳͲͱ༻ҙͨ͠ϑΝΠϧͰɺίϯς φىಈ࣌ʹݩͷϑΝΠϧʹ্ॻ͖͢Δ •
ڧͯ͘χϡʔήʔϜͰ͖Δ
install-plugin.sh • ެࣜJenkins Docker ͷػೳ • Πϯετʔϧ͍ͨ͠ plugin ͷҰཡΛॻ͍ͨϑΝΠϧΛ৯ ΘͤΔͱɺίϯςφىಈ࣌ʹ
ґଘ͢Δ plugin ؚΊͯΠ ϯετʔϧͯ͘͠ΕΔ • όʔδϣϯࢦఆՄೳ
-Djenkins.install.runSetupWizard=false • Jenkinsىಈ࣌ʹ͢JAVA_OPT • ॳճىಈ࣌ʹग़ͯ͘ΔɺΦεεϝϓϥάΠϯͷΠϯετʔ ϧηΩϡϦςΟઃఆͳͲΛεΩοϓͰ͖Δ • ࢲͷࢲʹΑΔࢲͷͨΊͷJenkinsʹෆཁͳͷͰઃఆ͢Δ
Jenkinsδϣϒͷཧ
ࢲͷͨΊͷJenkins͔ͩΒ ࢲ͕ϝϯςͰ͖Ε͍͍
GitHub Organization Plugin • Multibranch Pipeline ͷ GitHub ಛԽ൛ •
ࣗͷΞΧϯτΛࢦఆ͢Δ͚ͩͰɺJenkinsfile Λ࣋ͭ ϦϙδτϦΛݕग़ͯ͠উखʹϏϧυͯ͘͠ΕΔ • ࠓճ https://github.com/yasuhiroki/myJenkinsfile ͚ͩ Λݕग़͢ΔΑ͏ʹઃఆ
δϣϒ = ϒϥϯν • jobs/* ͱ͍͏໊લͷϒϥϯν͕ɺJenkinsͷδϣϒʹͳΔ Α͏ઃఆ͢Δ • jobs/sendo, jobs/today-is
ͳͲɺδϣϒຖʹϒϥϯνΛ࡞ Δ
git worktree ίϚϯυ • δϣϒ͝ͱʹ͍͍ͪͪ checkout ͢Δͷ໘ͳͷͰɺ git worktree ίϚϯυΛར༻͢Δ
• git worktree add jobs/today-is jobs/today-is ͱ͢Δͱɺ jobs/today-is σΟϨΫτϦʹ jobs/today-is ϒϥϯν͕ νΣοΫΞτ͞ΕΔ • ϒϥϯνͷ͚ͩσΟϨΫτϦΛ࡞ͬͯ checkout ͢Εɺ δϣϒͷઃఆ͕ू·ͬͨ jobs σΟϨΫτϦͷͰ͖͕͋Γ
Jenkinsfile • ࢲͷͨΊͷࣥࣄΛޏ͏ʹ Jenkinsfile ͕ඞਢ • https://jenkins.io/doc/book/pipeline/syntax/ ࣥࣄޏ༻ ϚχϡΞϧ
ϊʔυͷཧ
ϊʔυͷཧ2ύλʔϯ • Docker Pipeline plugin • jenkinsci/jnlp-slave Docker Πϝʔδ
Docker Pipeline plugin • JenkinsfileͰϏϧυΛ࣮ߦ͍ͨ͠ docker image Λࢦఆ͢ Δ •
Jenkinsίϯςφͱಉ͡ docker.sock Λ͏Α͏ઃఆ͢Ε ɺJenkinsίϯςφࣗମ৮ΕΔ • ༡ͼϙΠϯτ • ྫɿࣥࣄةػҰήʔϜ
jenkinsci/jnlp-slave • ϊʔυ༻ίϯςφΛىಈ͠JenkinsʹJNLPͰଓ͢Δ • ࣥࣄΛαϙʔτ͢ΔϝΠυతଘࡏ • େྔʹ༻ҙͯ͠ϝΠυୂΛ࡞Δͷ͕Φεεϝ • δϣϒͷϏϧυDocker PipelineͰࣄΓΔͷͰɺ
ϝΠυ͞Μͱ༡Ϳ͜ͱʹूத͢Δ͜ͱ
jenkinsci/jnlp-slave • *.override ͷػೳΛͬͯɺࣄલʹϊʔυͷใΛ Jenkinsʹ༻ҙ͓ͯ͘͠ͱॳظߏஙΛ΄΅ࣗಈԽͰ͖Δ • secret τʔΫϯҰ࡞ΒΕͨΒ JENKINS_HOME ҎԼ
Λ࡞Γ͞ͳ͍ݶΓಉ͡ͳͷͰࣗಈԽͰ͖Δ • ॳճ͚ͩखಈͰొ͕ඞཁ • groovy ͰΰϦΰϦΕશࣗಈԽͰ͖Δؾ͕͢Δ
·ͱΊ
JenkinsΛͰ͖Δ͚ͩImmutableͯ͠Έͨ • DockerͱGitHubͱJenkinsfileͰ͋ΔఔImmutableʹͰ͖Δ • GroovyεΫϦϓτͰΰϦΰϦ͠ͳͯ͘ɺ Chef Ansible ͰΰϦΰϦ͠ͳͯ͘ɺ ΦϨΦϨεΫϦϓτͰΰϦΰϦ͠ͳͯ͘ɺ
͋Δఔɺ࠶ߏஙՄೳͳJenkinsڥ͕खʹೖΔ ɹ˞ ͨͩ͠ Docker ͷ͕ࣝඞཁ • Ͱ͖Δ͚ͩJenkinsຊମͷઃఆΛݮΒ͢ͷ͕େࣄ
FIN