©2016 CloudBees, Inc. All Rights Reserved 1©2016 CloudBees, Inc. All Rights Reserved
Jenkins 2.0
川口耕介 / CTO / CloudBees, I...
©2016 CloudBees, Inc. All Rights Reserved 2
自己紹介
• 川口耕介
• Jenkinsを作った人
• CloudBeesの最高技術責任者
©2016 CloudBees, Inc. All Rights Reserved 3
©2016 CloudBees, Inc. All Rights Reserved 4
©2016 CloudBees, Inc. All Rights Reserved 5
©2016 CloudBees, Inc. All Rights Reserved 6
ビルド・エージェント総数 (2016年4月時点)
©2016 CloudBees, Inc. All Rights Reserved 7Copyright HBO
©2016 CloudBees, Inc. All Rights Reserved 8Copyright HBO
©2016 CloudBees, Inc. All Rights Reserved 9http://en.wikipedia.org/wiki/File:Grand-Bazaar_Shop.jpg
©2016 CloudBees, Inc. All Rights Reserved 10
©2016 CloudBees, Inc. All Rights Reserved 11
©2016 CloudBees, Inc. All Rights Reserved 12
次の10年
©2016 CloudBees, Inc. All Rights Reserved 13
©2016 CloudBees, Inc. All Rights Reserved 14
©2016 CloudBees, Inc. All Rights Reserved 15
©2016 CloudBees, Inc. All Rights Reserved 16
#1: 広がりつづける自動化の波
©2016 CloudBees, Inc. All Rights Reserved 17
©2016 CloudBees, Inc. All Rights Reserved 18
©2016 CloudBees, Inc. All Rights Reserved 19
©2016 CloudBees, Inc. All Rights Reserved 20
©2016 CloudBees, Inc. All Rights Reserved 21
Source: State of Jenkins Survey Sept. 2015
Jenkinsの利用の拡大
©2016 CloudBees, Inc. All Rights Reserved 22
2013 調査 2015 調査
Jenkinsはミッションクリティカルな存在ですか?
©2016 CloudBees, Inc. All Rights Reserved 23
2013 2015
ビルド 95% 97%
テスト 86% 90%
デプロイ 48% 58%
運用 15% 24%
Jenkinsの用途は?
©2016 CloudBees, Inc. All Rights Reserved 24
どのレベルの自動化を達成しましたか?
59%
30%
11%
CI
CD+手動デプロイ
CD+自動デプロイ
©2016 CloudBees, Inc. All Rights Reserved 25
©2016 CloudBees, Inc. All Rights Reserved 26
#2: コード→○ GUI→× ステート→×
©2016 CloudBees, Inc. All Rights Reserved 27
コード→○ GUI→× ステート→×
• 変更を見える化
• 結果でなく意図を記録する
• 冗長さを避ける
• 大規模になっても大丈夫
©2016 CloudBees, Inc. All Rights Reserved 28
Credit: https://flic.kr/p/nrFHFz
©2016 CloudBees, Inc. All Rights Reserved 29©2016 CloudBees, Inc. All Rights Reserved
パイプラインを作ってみよう
©2016 CloudBees, Inc. All Rights Reserved 30
パイプラインを作ってみよう
©2016 CloudBees, Inc. All Rights Reserved 31
パイプラインを作ってみよう
©2016 CloudBees, Inc. All Rights Reserved 32
パイプラインを作ってみよう
©2016 CloudBees, Inc. All Rights Reserved 33
Jenkinsfile
node('java8') {
// Checkout our source code
stage 'Checkout'
chec...
©2016 CloudBees, Inc. All Rights Reserved 34
並列処理
parallel(
windows: {
// run test on windows
node('windows') {
checkout s...
©2016 CloudBees, Inc. All Rights Reserved 35
クリーンアップ処理
try {
sh './test.sh'
} finally {
sh './clean.sh'
}
©2016 CloudBees, Inc. All Rights Reserved 36
人間の作業を含める
def releaseId = input(
message:'リリースノートを更新してリリースIDを入力してください',
param...
©2016 CloudBees, Inc. All Rights Reserved 37
実行結果の表示
©2016 CloudBees, Inc. All Rights Reserved 38
GitHub Organization Folder
©2016 CloudBees, Inc. All Rights Reserved 39
Organization Folderの利点
• Jenkinsの設定は一度だけ
• Jenkinsfileをコミットするだけ
• ブランチ別のビルド履歴...
©2016 CloudBees, Inc. All Rights Reserved 40©2016 CloudBees, Inc. All Rights Reserved
パイプラインのドキュメント
jenkins.io/doc
©2016 CloudBees, Inc. All Rights Reserved 41
ドキュメント
©2016 CloudBees, Inc. All Rights Reserved 42
ドキュメント localhost:8080/workflow-cps-snippetizer/dslReference
©2016 CloudBees, Inc. All Rights Reserved 43©2016 CloudBees, Inc. All Rights Reserved
パイプラインでこんなことも
©2016 CloudBees, Inc. All Rights Reserved 44
Dockerイメージのビルド
def imageName = 'jenkinsciinfra/bind'
node('docker') {
checkou...
©2016 CloudBees, Inc. All Rights Reserved 45
ツールコンテナの活用
node('docker') {
// The `docker` variable introduced by the plugin...
©2016 CloudBees, Inc. All Rights Reserved 46
プラグインが豊かにするパイプライン
node {
...
if (env.BRANCH_NAME == 'master') {
sshagent(cred...
©2016 CloudBees, Inc. All Rights Reserved 47
プラグインが豊かにするパイプライン
node {
// Print timestamps for all the wrapped steps
wrap([...
©2016 CloudBees, Inc. All Rights Reserved 48
プラグインが豊かにするパイプライン
node {
stage "Build and test"
timeout(time: 180, unit: 'MIN...
©2016 CloudBees, Inc. All Rights Reserved 49©2016 CloudBees, Inc. All Rights Reserved
パイプラインの抽象化と再利用
©2016 CloudBees, Inc. All Rights Reserved 50
Dockerイメージのビルド x100 ?
def imageName = 'jenkinsciinfra/bind'
node('docker') {
...
©2016 CloudBees, Inc. All Rights Reserved 51
container_build 'jenkinsciinfra/bind'
©2016 CloudBees, Inc. All Rights Reserved 52
vars/container_build.groovy
def call(imageName) {
node('docker') {
checkout s...
©2016 CloudBees, Inc. All Rights Reserved 53
まとめ: パイプライン
• 複雑な処理が必要な時にうってつけ
• テキストで記述してバージョン管理
• ジョブが多くてもテンプレート化
• Jenkins...
©2016 CloudBees, Inc. All Rights Reserved 54
©2016 CloudBees, Inc. All Rights Reserved 55
#3: UIの改善
©2016 CloudBees, Inc. All Rights Reserved 56
#4: 「要組み立て」からの脱却
©2016 CloudBees, Inc. All Rights Reserved 57
©2016 CloudBees, Inc. All Rights Reserved 58
©2016 CloudBees, Inc. All Rights Reserved 59
• お勧めプラグインが最初からついてくる
– 8割の機能を最初から搭載
– ベスト・プラクティスにユーザーを誘導する
Jenkins 2.0 では…
©2016 CloudBees, Inc. All Rights Reserved 60
• プラグイン同士がオー
バーラップする部分の
面倒を見られる
• 開発とQA資源の集中
標準の機能を豊かにするメリット
©2016 CloudBees, Inc. All Rights Reserved 61
ドキュメンテーション
©2016 CloudBees, Inc. All Rights Reserved 62
#5: ユーザーを守る
©2016 CloudBees, Inc. All Rights Reserved 63https://flic.kr/p/otBTLe
©2016 CloudBees, Inc. All Rights Reserved 64
• セキュリティ・チームの発足
• セキュリティ・チームとリリース・チームの連携
• セキュリティ勧告と事前アナウンスメント
• アプリ内でのユーザーの誘...
©2016 CloudBees, Inc. All Rights Reserved 65
• 最初からより安全なディフォルト
2.0ではまた一歩先へ
©2016 CloudBees, Inc. All Rights Reserved 66
• 一からやり直したわけではなく、コアは1.xと同じ
系列
• 今までと同じアップデートの仕方で!
後方互換性もバッチリ
©2016 CloudBees, Inc. All Rights Reserved 67
まとめ: Jenkins 2.0
• Pipeline as Code
• UIの改善
• 「要組み立て」からの脱却
• セキュリティ
• CI → CDへ
Upcoming SlideShare
Loading in …5
×

Jenkins 2.0 (日本語)

1,002 views
816 views

Published on

日本語によるJenkins 2.0の紹介

Published in: Software
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,002
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide
  • And no one is slowing down!

    With CloudBees unique perspective of Jenkins usage, the growth is driving our business as well. Expansion in Jenkins adoption is why we’re seeing over 150% growth in our business, which focuses on just a fraction of the global users.
  • Let’s assume you have Jenkins 2.0 running, using the suggested plugins


    -> When you click on “New Item”, in addition to the new look, you’ll see “Pipeline” ->

  • -> For this demo we’ll just create a simple Pipeline called “Niagara” ->
  • Inside the usual job configuration you’ll find a PIpeline script text area
    In this example, we’ve inserted the Hello World example

    -> There’s a lot going on in this screenshot
  • Inside the usual job configuration you’ll find a PIpeline script text area
    In this example, we’ve inserted the Hello World example

    -> There’s a lot going on in this screenshot
  • This is a very simple Jenkinsfile, just like one you might check into a repository
    It defines three stages:
    Checkout
    Build
    Test
    This just a basic example, but if you can imagine how this was once configured in the Jenkins Web UI.
    Now this can be checked in, with an audit trail and easily evolve alongside the project

    -> This is basic, just using built-in steps ->
  • This is a very simple Jenkinsfile, just like one you might check into a repository
    It defines three stages:
    Checkout
    Build
    Test
    This just a basic example, but if you can imagine how this was once configured in the Jenkins Web UI.
    Now this can be checked in, with an audit trail and easily evolve alongside the project

    -> This is basic, just using built-in steps ->
  • This is a very simple Jenkinsfile, just like one you might check into a repository
    It defines three stages:
    Checkout
    Build
    Test
    This just a basic example, but if you can imagine how this was once configured in the Jenkins Web UI.
    Now this can be checked in, with an audit trail and easily evolve alongside the project

    -> This is basic, just using built-in steps ->
  • This is a very simple Jenkinsfile, just like one you might check into a repository
    It defines three stages:
    Checkout
    Build
    Test
    This just a basic example, but if you can imagine how this was once configured in the Jenkins Web UI.
    Now this can be checked in, with an audit trail and easily evolve alongside the project

    -> This is basic, just using built-in steps ->
  • The snippet generator can be used to prorotype snippets of Pipeline
  • and in text / not just calling other jobs, but do stuff within itself
  • Jenkins 2.0 (日本語)

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

    ×