Herokuで実践するCI/CD
Salesforce  Developer  Web  セミナー
tabe@salesforce.com
@sho7650
​ 阿部  崇  (Takashi  Abe)
​ Platform  Specialist
Forward-‐‑‒Looking  Statements
‹#›  |  ©2017  Salesforce
​ Statement under the Private Securities Litigation Reform Act of 1995:
​ This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or
if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the
forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any
projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies
or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology
developments and customer contracts or use of our services.
​ The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for
our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of
growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed
and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand,
retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history
reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could
affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly
report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC
Filings section of the Investor Information section of our Web site.
​ Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may
not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently
available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
本⽇日のセミナー内容
3  |  ©2017  Salesforce
内容
•  継続的デリバリーの流流れ(継続的インテグレーション・デプロイ)を理理解する
•  Heroku CI と Heroku Pipelines で継続的デリバリーの使い⽅方を学ぶ
対象者
•  アプリケーション開発者
•  ターミナルでコマンド操作ができる⼈人
•  Github を使えている⼈人
•  Heroku を使ってみたい・使っている⼈人
•  Salesforce が好きな⼈人
ゴール •  Heroku CI と Heroku Pipelines を設定して、フローを回すことができる
今⽇日の流流れ
4  |  ©2017  Salesforce
継続的デプロイ
について理理解する
GitHubとの連携
Heroku  CI  で
⾃自動テスト
Heroku  Pipelines
での⾃自動化
ü 最後に質問への回答の時間を設けます
ü 質問はいつでも送ってください
話者紹介
Heroku  Webinar  担当  (3週間ぶり5回⽬目)
    今⽇日の解説者
阿  部    崇 (Takashi Abe)
Platform Specialist (@sho7650)
アプリエンジニア  à HWエンジニア  à インフラエンジニア
à アーキテクト兼ITコンサル  à 現職
ライブと熱帯⿂魚が好き: Perfume/BABYMETAL/藤原さくら/稲川淳⼆二
IT業界を取り巻く環境
今、将来、ITエンジニアに求められるものとは
デジタル⼤大変⾰革時代、変化への即応性と俊敏性
​ ⽇日本でも、デジタルトランスフォーメーションが現実化。俊敏性が重要。
社内に既存の技術力はあり、加えて具体的な技術(データ解
析やAI、クラウド等)が求められている。また、具体的な要素
技術だけでなく、システムの構造設計を行い開発する能力
(システムアーキテクト)の重要	
「IT人材白書2017」よりP.10	
「IT人材白書2017」図表2-1-1より P.27	
「IT⼈人材⽩白書2017」図表1-1-1より  P.4
「IT人材白書2017」図表2-1-4より P.29
Charles  Darwin  (1809-‐‑‒1882)
「種の起源」
強い者、頭の良良い者が⽣生き残るのではない。
変化するものが⽣生き残るのだ
​ 「強い者、賢い者が勝つのではなく、早い(速い)者が勝つ」
(ユニ・チャームの精神  –  3つのDNA  から)
DevOps  ムーブメントの原動⼒力力となっている要因
​ 継続的なイノベーションのためにDevOpsを導⼊入する  (IBM  Developer  Works)
10 | ©2017 Salesforce
継続的なイノベーションのためにDevOps  を導⼊入する  (https://www.ibm.com/developerworks/jp/devops/library/d-‐‑‒devops-‐‑‒continuous-‐‑‒innovation/index.html)
4 顧客は、使⽤用中のどのプラットフォームからでも、最新の機能に
アクセスし、それらを使⽤用できることを求めている
3 運⽤用担当者は、要求に応じて環境をプロビジョニングできるように
なっている
2 開発者は、機能を毎⽇日次々に開発している
1 事業主は、アジリティー  (俊敏性)  を求めている
とは⾔言え、
開発者の悩みは尽きない
アプリケーションの開発・デプロイには悩みが多い
アプリ開発者 アプリ利利⽤用者
開発
•  アジャイルだからって、毎⽇日、ソー
スコードをコミットする度度に、コン
パイルしてユニットテストを⼿手で回
すなんて、現実的じゃない...
•  デプロイする環境はあるかな...
•  ウォーターフォールなので、テス
トも、開発フェーズじゃユニット
テストしかやらないから、ほんと
に動くのかどうか、数ヶ⽉月後じゃ
ないとわからない...
•  エクセルにテスト結果貼らな
きゃ...
これらを”うまく”まわす仕組みを⾃自前で構築・管理理していくのは⼤大変
ビルド  (コンパイルàテストàリリース)  &  デプロイを断続的・継続的に実現することが必要不不可⽋欠  
ビルド テスト リリース
継続的な機能追加・改修・テスト・デプロイが求められてるが...
デプロイ
これらを解決していくには...?
Continuous  Model
継続モデル
継続的〜~を理理解して、俊敏性の⾼高い開発モデルを実現
継続的〜~はいろいろあるが、結局何か
​ 実現する範囲によって、継続的〜~の実現要素が変わる
Code
開発
Build
ビルド
Test
テスト
Release
リリース
Deploy
デプロイ
Operate
運⽤用
アジャイル開発
継続的インテグレーション
継続的デリバリー
継続的デプロイメント
DevOps
Continuous  
Integration
継続的インテグレーション
「動作する」ソフトウェアを短期間に開発
継続的インテグレーション(CI)は何か
​ 動作するソフトウェアを短期間に開発したい
開発
ビルドテスト
継続的インテグレーションの⽬目的
​ ソフトウェア開発の「リスクを削減」する
17 | ©2017 Salesforce
1 リスクを軽減する
2 繰り返しが多い⼿手作業の削減
3 デプロイ可能なソフトウェア
4 プロジェクトの⾒見見える化
5 開発チームの⾃自信を深める
出典:  「継続的インテグレーション⼊入⾨門」⽇日経BP社
Continuous  Delivery
継続的デリバリー
動作するソフトウェアを、いつでもリリース可能
継続的デリバリー(CD)は何か
​ 開発されたソフトウェアを、常にデプロイできる状態を保つ
開発
ビルド
テスト
リリース
継続的デリバリーの⽬目的
​ 開発中のソフトウェアを、いつでもデプロイできる状態にすること
20 | ©2017 Salesforce
“The key test is that a business sponsor could request that the current development version
of the software can be deployed into production at a moment's notice”
– Martin Fowler (https://martinfowler.com/bliki/ContinuousDelivery.html )
「今、開発中のバージョンを、すぐに本番環境にデプロイしろ」
という、お客様からのリクエストに対処できるか
参考(Deployment  Pipeline)  http://martinfowler.com/bliki/DeploymentPipeline.html
Continuous  
Deployment
継続的デプロイ
利利⽤用可能なソフトウェアを、常にリリース&デプロイ
継続的デプロイ(CD)とは何か
​ ソフトウェアを、いつでも、どこでも、最⼩小限の労⼒力力でリリース
開発
ビルド
テストリリース
デプロイ
継続的デプロイの⽬目的と7つの重要なポイント
​ ソフトウェアの変化を最速で提供し、企業価値を創出
23 | ©2017 Salesforce
1
動作するソフトウェアを
常にリリース  &  デプロイ
2 リポジトリ資産へラベリング
3 クリーンな環境の構築
4 個々のビルドにラベリング
5 すべてのテストの実⾏行行
6
ビルドフィードバック
レポート
7 ロールバックが可能なこと
出典: 「継続的インテグレーション入門」日経BP社
Heroku  CI/CD
Heroku  が提供する  CI/CD  の⾃自動化機能
CI/CD  を実現するための機能を備えたプラットフォーム
​ Heroku  は、Heroku  CI  と  Heroku  Pipelines  を組み合わせて、CI/CDを提供
開発
ビルド
テストリリース
デプロイ
GitHub  Flow  とHeroku  は連携しやすい開発スタイル
​ プルリクエストと連動して、アプリ環境を⾃自動的に⽣生成
Update index.html
Create readmore.md
master
Hammertime
Heroku  CI
​ 継続的インテグレーションを⽀支える、⾃自動テスト機能を提供
https://devcenter.heroku.com/articles/heroku-ci
テストの結果を
ダッシュボードか
ら確認可能!
過去のテスト内容も
みられるよ!
Heroku  Pipelines
​ 継続的デリバリー・デプロイを実現するための便便利利なワークフロー
https://devcenter.heroku.com/articles/pipelines
プルリクエストと
連動してCIを実現!!
デプロイ状況が、画⾯面で
⼀一望できるね
Heroku  CI/CD  DEMO
実際に⾒見見てみましょう
今回のデモシナリオ
​ CodeZine「Herokuとチーム開発のおいしいレシピ」の内容をデモ実演
1 改修⽤用のブランチで、ソースコードの改修とプッシュ
2 テストの結果を確認して、プルリクエスト
3 master  ブランチへマージ、ステージング環境で確認
4 本番環境へデプロイ!
CodeZine:  「Herokuとチーム開発のおいしいレシピ〜~HerokuとGitHubを連携してCI/CDを実現する」  https://codezine.jp/article/detail/10233
今回のデモ環境
Ø  macOS  sierra
Ø  Atom  /  vi
Ø  ターミナル  /  iTerm
• Heroku  CLI
• Git  CLI
デモのおさらい
​ ⼿手順の確⽴立立したデプロイパイプラインに従って、安全にリリース  &  デプロイ
ローカル:  リポジトリ
GitHub:  リポジトリ
Heroku  CI
Heroku:  Review  Apps
Heroku:  STAGING
Heroku:  PRODUCTION
git  clone
コード改修
git  push
⾃自動テスト
テスト結果
プルリクエスト
アプリテスト
マージ
テスト完了了待ち
⾃自動テスト
受⼊入テスト
デプロイ!
(Promote!!)
Heroku  アプリケーション環境
1.改修とプッシュ 2.プルリクエスト 3.master  ブランチへマージしてステージング環境でテスト 4.デプロイ
​ Heroku  は開発者の皆さまを、様々なしがらみから開放します
今⽇日のまとめ
ITエンジニアの⽴立立場 •  迅速で、かつ変化に対応できる ITエンジニアが求められる
継続的デリバリー
(継続的インテグレーション/デプロイ)
•  いつでもソフトウェアをリリースできる流流れ
•  ⾃自動ビルド&デプロイにより、継続的デリバリーを実現
Heroku CI/CD
•  Heroku CI は⾃自動テストを実現
•  Heroku Pipelines は⾃自動ビルド&デプロイを⽀支援
次のステップへ...Trailhead
Heroku  Enterpriseの基礎
Heroku  Enterpriseをいつ
どのように使⽤用するかに
ついての基礎を学習します
SalesforceとHerokuの  
インテグレーション
Herokuのアプリケーションを
Salesforceに統合するための
パターンと⽅方法を学びます
https://trailhead.salesforce.com/ja
34  |  ©2017  Salesforce
Thank Y u

Herokuで実践するCI, CD