Download - Jenkins 2.0 (日本語)
![Page 1: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/1.jpg)
©2016 CloudBees, Inc. All Rights Reserved 1©2016 CloudBees, Inc. All Rights Reserved
Jenkins 2.0川口耕介 / CTO / CloudBees, [email protected] / @kohsukekawa
![Page 2: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/2.jpg)
©2016 CloudBees, Inc. All Rights Reserved 2
自己紹介
• 川口耕介• Jenkins を作った人• CloudBees の最高技術責任者
![Page 3: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/3.jpg)
©2016 CloudBees, Inc. All Rights Reserved 3
![Page 4: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/4.jpg)
©2016 CloudBees, Inc. All Rights Reserved 4
![Page 5: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/5.jpg)
©2016 CloudBees, Inc. All Rights Reserved 5
![Page 6: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/6.jpg)
©2016 CloudBees, Inc. All Rights Reserved 6
ビルド・エージェント総数 (2016 年 4 月時点 )
400,000
![Page 7: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/7.jpg)
©2016 CloudBees, Inc. All Rights Reserved 7Copyright HBO
![Page 8: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/8.jpg)
©2016 CloudBees, Inc. All Rights Reserved 8Copyright HBO
![Page 9: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/9.jpg)
©2016 CloudBees, Inc. All Rights Reserved 9http://en.wikipedia.org/wiki/File:Grand-Bazaar_Shop.jpg
![Page 10: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/10.jpg)
©2016 CloudBees, Inc. All Rights Reserved 10
![Page 11: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/11.jpg)
©2016 CloudBees, Inc. All Rights Reserved 11
![Page 12: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/12.jpg)
©2016 CloudBees, Inc. All Rights Reserved 12
次の 10 年
![Page 13: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/13.jpg)
©2016 CloudBees, Inc. All Rights Reserved 13
![Page 14: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/14.jpg)
©2016 CloudBees, Inc. All Rights Reserved 14
![Page 15: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/15.jpg)
©2016 CloudBees, Inc. All Rights Reserved 15
![Page 16: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/16.jpg)
©2016 CloudBees, Inc. All Rights Reserved 16
#1: 広がりつづける自動化の波
![Page 17: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/17.jpg)
©2016 CloudBees, Inc. All Rights Reserved 17
![Page 18: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/18.jpg)
©2016 CloudBees, Inc. All Rights Reserved 18
![Page 19: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/19.jpg)
©2016 CloudBees, Inc. All Rights Reserved 19
![Page 20: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/20.jpg)
©2016 CloudBees, Inc. All Rights Reserved 20
![Page 21: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/21.jpg)
©2016 CloudBees, Inc. All Rights Reserved 21Source: State of Jenkins Survey Sept. 2015
Jenkins の利用の拡大
![Page 22: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/22.jpg)
©2016 CloudBees, Inc. All Rights Reserved 22
2013 調査 2015 調査
Jenkins はミッションクリティカルな存在ですか?
83% 92%
![Page 23: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/23.jpg)
©2016 CloudBees, Inc. All Rights Reserved 23
2013 2015
ビルド 95% 97%
テスト 86% 90%
デプロイ 48% 58%
運用 15% 24%
Jenkins の用途は?
![Page 24: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/24.jpg)
©2016 CloudBees, Inc. All Rights Reserved 24
どのレベルの自動化を達成しましたか?
59%30%
11%
CI
CD+手動デプロイCD+自動デプロイ
![Page 25: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/25.jpg)
©2016 CloudBees, Inc. All Rights Reserved 25
![Page 26: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/26.jpg)
©2016 CloudBees, Inc. All Rights Reserved 26
#2: コード→○ GUI→× ステート→ ×
![Page 27: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/27.jpg)
©2016 CloudBees, Inc. All Rights Reserved 27
コード→○ GUI→× ステート→ ו 変更を見える化• 結果でなく意図を記録する• 冗長さを避ける• 大規模になっても大丈夫
![Page 28: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/28.jpg)
©2016 CloudBees, Inc. All Rights Reserved 28Credit: https://flic.kr/p/nrFHFz
![Page 29: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/29.jpg)
©2016 CloudBees, Inc. All Rights Reserved 29©2016 CloudBees, Inc. All Rights Reserved
パイプラインを作ってみよう
![Page 30: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/30.jpg)
©2016 CloudBees, Inc. All Rights Reserved 30
パイプラインを作ってみよう
![Page 31: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/31.jpg)
©2016 CloudBees, Inc. All Rights Reserved 31
パイプラインを作ってみよう
![Page 32: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/32.jpg)
©2016 CloudBees, Inc. All Rights Reserved 32
パイプラインを作ってみよう
![Page 33: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/33.jpg)
©2016 CloudBees, Inc. All Rights Reserved 33
Jenkinsfilenode('java8') { // Checkout our source code stage 'Checkout' checkout scm
// Build our project stage 'Build' sh 'mvn clean install'
// Run our test target stage 'Test' sh './test.sh'
// Archive our artifacts archive 'target/**/*.jar'}
![Page 34: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/34.jpg)
©2016 CloudBees, Inc. All Rights Reserved 34
並列処理parallel( windows: { // run test on windows node('windows') { checkout scm sh './test.bat' } }, linux: { // run test on linux node('linux') { checkout scm sh './test.sh' } })
![Page 35: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/35.jpg)
©2016 CloudBees, Inc. All Rights Reserved 35
クリーンアップ処理try { sh './test.sh'} finally { sh './clean.sh'}
![Page 36: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/36.jpg)
©2016 CloudBees, Inc. All Rights Reserved 36
人間の作業を含めるdef releaseId = input( message:'リリースノートを更新してリリース IDを入力してください ', parameters: [ [$class: 'TextParameterDefinition', name: 'id'] ])sh "./upload.sh ${releaseId}"
![Page 37: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/37.jpg)
©2016 CloudBees, Inc. All Rights Reserved 37
実行結果の表示
![Page 38: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/38.jpg)
©2016 CloudBees, Inc. All Rights Reserved 38
GitHub Organization Folder
![Page 39: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/39.jpg)
©2016 CloudBees, Inc. All Rights Reserved 39
Organization Folder の利点
• Jenkins の設定は一度だけ• Jenkinsfile をコミットするだけ• ブランチ別のビルド履歴• プルリクエストの自動ビルドと結果の通知
![Page 40: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/40.jpg)
©2016 CloudBees, Inc. All Rights Reserved 40©2016 CloudBees, Inc. All Rights Reserved
パイプラインのドキュメント
jenkins.io/doc
![Page 41: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/41.jpg)
©2016 CloudBees, Inc. All Rights Reserved 41
ドキュメント
![Page 42: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/42.jpg)
©2016 CloudBees, Inc. All Rights Reserved 42
ドキュメント localhost:8080/workflow-cps-snippetizer/dslReference
![Page 43: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/43.jpg)
©2016 CloudBees, Inc. All Rights Reserved 43©2016 CloudBees, Inc. All Rights Reserved
パイプラインでこんなことも
![Page 44: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/44.jpg)
©2016 CloudBees, Inc. All Rights Reserved 44
Docker イメージのビルド
def imageName = 'jenkinsciinfra/bind'
node('docker') {checkout scm
// Compute a unique image tagdef imageTag = "build-${env.BUILD_NUMBER}"
// The `docker` variable introduced by the pluginstage 'Build'def whale = docker.build("${imageName}:${imageTag}")
// Publish this image to Docker Hubstage 'Deploy'whale.push()
}
![Page 45: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/45.jpg)
©2016 CloudBees, Inc. All Rights Reserved 45
ツールコンテナの活用
node('docker') {// The `docker` variable introduced by the plugin.//// Invoking our Gradle build inside a freshly spun up// Docker container with JDK8docker.image('java:8-jdk').inside {
checkout scmsh './gradlew --info'archive 'build/libs/**/*.jar'
}}
![Page 46: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/46.jpg)
©2016 CloudBees, Inc. All Rights Reserved 46
プラグインが豊かにするパイプライン
node {...
if (env.BRANCH_NAME == 'master') {sshagent(credentials: ['my-credential-uuid']) {
sh './run-ssh-deploy-script'}
}}
![Page 47: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/47.jpg)
©2016 CloudBees, Inc. All Rights Reserved 47
プラグインが豊かにするパイプライン
node {// Print timestamps for all the wrapped stepswrap([$class: 'TimestamperBuildWrapper']) {
checkout scmsh 'mvn clean install'
} // Archive our artifacts archive 'target/**/*.jar'}
github.com/jenkinsci/pipeline-examples
![Page 48: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/48.jpg)
©2016 CloudBees, Inc. All Rights Reserved 48
プラグインが豊かにするパイプライン
node {stage "Build and test"timeout(time: 180, unit: 'MINUTES') {
sh "mvn clean install -Dmaven.repo.local=${pwd()}/.repository"}
stage "Archive test results"step([$class: 'JUnitResultArchiver',
healthScaleFactor: 20.0,testResults: '**/target/surefire-reports/*.xml'])
}
![Page 49: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/49.jpg)
©2016 CloudBees, Inc. All Rights Reserved 49©2016 CloudBees, Inc. All Rights Reserved
パイプラインの抽象化と再利用
![Page 50: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/50.jpg)
©2016 CloudBees, Inc. All Rights Reserved 50
Docker イメージのビルド x100 ?
def imageName = 'jenkinsciinfra/bind'
node('docker') {checkout scm
// Compute a unique image tagdef imageTag = "build-${env.BUILD_NUMBER}"
// The `docker` variable introduced by the pluginstage 'Build'def whale = docker.build("${imageName}:${imageTag}")
// Publish this image to Docker Hubstage 'Deploy'whale.push()
}
![Page 51: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/51.jpg)
©2016 CloudBees, Inc. All Rights Reserved 51
container_build 'jenkinsciinfra/bind'
![Page 52: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/52.jpg)
©2016 CloudBees, Inc. All Rights Reserved 52
vars/container_build.groovy
def call(imageName) { node('docker') {
checkout scm
// Compute a unique image tagdef imageTag = "build-${env.BUILD_NUMBER}"
// The `docker` variable introduced by the pluginstage 'Build'def whale = docker.build("${imageName}:${imageTag}")
// Publish this image to Docker Hubstage 'Deploy'whale.push()
}}
![Page 53: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/53.jpg)
©2016 CloudBees, Inc. All Rights Reserved 53
まとめ : パイプライン
• 複雑な処理が必要な時にうってつけ• テキストで記述してバージョン管理• ジョブが多くてもテンプレート化• Jenkins を再起動しても続く
![Page 54: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/54.jpg)
©2016 CloudBees, Inc. All Rights Reserved 54
![Page 55: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/55.jpg)
©2016 CloudBees, Inc. All Rights Reserved 55
#3: UI の改善
![Page 56: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/56.jpg)
©2016 CloudBees, Inc. All Rights Reserved 56
#4: 「要組み立て」からの脱却
![Page 57: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/57.jpg)
©2016 CloudBees, Inc. All Rights Reserved 57
![Page 58: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/58.jpg)
©2016 CloudBees, Inc. All Rights Reserved 58
![Page 59: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/59.jpg)
©2016 CloudBees, Inc. All Rights Reserved 59
• お勧めプラグインが最初からついてくる–8割の機能を最初から搭載–ベスト・プラクティスにユーザーを誘導する
Jenkins 2.0 では…
![Page 60: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/60.jpg)
©2016 CloudBees, Inc. All Rights Reserved 60
• プラグイン同士がオーバーラップする部分の面倒を見られる
• 開発と QA 資源の集中
標準の機能を豊かにするメリット
![Page 61: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/61.jpg)
©2016 CloudBees, Inc. All Rights Reserved 61
ドキュメンテーション
![Page 62: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/62.jpg)
©2016 CloudBees, Inc. All Rights Reserved 62
#5: ユーザーを守る
![Page 63: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/63.jpg)
©2016 CloudBees, Inc. All Rights Reserved 63https://flic.kr/p/otBTLe
![Page 64: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/64.jpg)
©2016 CloudBees, Inc. All Rights Reserved 64
• セキュリティ・チームの発足• セキュリティ・チームとリリース・チーム
の連携• セキュリティ勧告と事前アナウンスメント• アプリ内でのユーザーの誘導
今までも一歩一歩改善してきた
![Page 65: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/65.jpg)
©2016 CloudBees, Inc. All Rights Reserved 65
• 最初からより安全なディフォルト
2.0 ではまた一歩先へ
![Page 66: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/66.jpg)
©2016 CloudBees, Inc. All Rights Reserved 66
• 一からやり直したわけではなく、コアは1.x と同じ系列
• 今までと同じアップデートの仕方で!
後方互換性もバッチリ
![Page 67: Jenkins 2.0 (日本語)](https://reader031.vdocuments.pub/reader031/viewer/2022012914/586fb99d1a28abe57d8b84b1/html5/thumbnails/67.jpg)
©2016 CloudBees, Inc. All Rights Reserved 67
まとめ : Jenkins 2.0• Pipeline as Code• UI の改善• 「要組み立て」からの脱却• セキュリティ
• CI → CD へ