SlideShare a Scribd company logo
1 of 33
Download to read offline
CircleCIで始めるCI/CD導入の基本と
導入事例の紹介
自己紹介
名前:松永 真季
所属: CI事業部 MSP開発セクション@大阪オフィス
入社: 2020年 1月入社
担当:アプリケーションエンジニア
アジェンダ
- CI/CDとは
- CI/CDの代表サービスのCircleCIの紹介
- 導入実例と導入後の効果について
CI/CDとは
CI/CD
テスト ビルド デプロイ
ソースコードの
変更
本番環境
ステージング
環境
開発環境
反映
ソフトウェアに変更が発生するたびに
テスト、ビルド、デプロイを自動化する開発手法のこと。
CircleCI概要
CI/CDツール
テスト ビルド デプロイ
ソースコードの
変更
本番環境
ステージング
環境
開発環境
反映
CircleCIの
オススメポイント
- SaaS型/オンプレ型選択可能なCI/CDサービス
- SaaS型の場合CircleCIはクラウド上のコンテナまたはVM上で動作する
→ 管理コストが低い
- CircleCI Runnerという自社で管理しているサーバをCircleCIのビルドサーバと
して利用することが出来る機能が最近リリースされた(2020年11月)👏
- ymlファイルで手順を一括設定できる
- 従量課金なので利用料には要注意
- GitHub/Bitbucketとの連携が必須
料金プラン
- 料金プランによって使用できる機能が異なります
https://circleci.com/ja/pricing/
今回はCircleCIでシステムの
テスト、ビルド、デプロイ
を自動化しました
導入したシステムの紹介(一例)
アイレットが提供する、
クラウドの導入設計から構築・運用・監視保守をするマネージドサービス
MSPチームが24時間365日でサーバーを監視してお客様のインフラ環境やITシステムの安定運用を実現しています。
アラートや障害が発生した時の一次対応をするシステムに導入
明日12月18日(金)、夜8時開催!
導入理由
- システム改修後のリリース作業の時間を削減したい
→ リリース回数も割とある(月1、2回)。効果がわかりやすそう
- リリースまでに手作業が多いのでケアレスミス発生の可能性をなくしたい
導入前
※自前のスクリプトを手動で実行1.実装 2.テスト
実装完了&テストPass 確認後にgit commit & push
※自前のスクリプトを手動で実行
2.ビルド
自前のスクリプトを手動実行しそれぞれの環境へ反映
3.デプロイ 本番環境
ステージング
環境
開発環境
※自前のスクリプトを手動で実行
開発時
リリース時
1.環境設定
※自前のスクリプトを手動で実行
CircleCI実行トリガー
CI(自動テスト)実行トリガー
- GitHub開発用featureブランチにpushした時
→ テストスクリプトを自動実行
CD(自動テスト〜ビルド〜デプロイ)実行トリガー
- GitHubで特定のブランチへmergeした時
→ mergeされたブランチごとにデプロイ先環境を設定
導入後
※自前のスクリプトを自動実行
実装
git push
本番環境
ステージング
環境
開発環境
開発時
リリース時
テストの結果を通知。テスト漏れがあってもすぐに気づく!
git push
main(master)ブランチへ
マージ
releaseブランチへ
マージ
developブランチへ
マージ
変更を通知
1〜3の実行結果を通知。失敗してもすぐ気づく!
変更を通知
変更を通知
変更を通知
導入効果
- 従来のリリース作業時間が約23%減
- テスト実施漏れがなくなった
→ 早い段階でエラーに気づく
- 手作業による作業ミスの発生率0%に
CircleCI導入手順
事前準備
- Git Hubアカウント/レポジトリの作成
- CircleCIアカウントの作成
- Git HubアカウントとCircleCIアカウントの連携設定
事前準備
Config.yml作成
- 設定は全て.circleci/config.yml に記載します。
- CI/CDを実行する対象Gitレポジトリのルートに用意します
Config.yml構成①
バージョン指定(必須)
ジョブを定義(必須)
ジョブが動作するコンテナ環境を指定
ジョブ実行内容を記載(記載順に実行される)
【Docker hub by CircleCI】
テストjob
ビルドjob
デプロイjob
ジョブが動作するVM環境を指定
Config.yml構成②
ワークフロー(パイプライン)
- ジョブの実行順を指定できる
- シーケンシャル処理
- 並列処理
- ジョブを実行するgithubブランチを指定できる
シーケンシャル処理
並列処理
Web-UI
ジョブ(クリックで詳細画面へ遷移)
ワークフロー(パイプライン)
結果
環境変数の設定
Project Settings > environment-variables
Config.ymlを簡潔に書く工夫
- CircleCI Orbsの使用
- Parametersの使用
- コマンドのスクリプト化
CircleCI Orbs①
- config.ymlに定義する設定をパッケージングし、再利用できる仕組み
- Version :2.1以上
- Slack通知したい
- AWSコマンドを叩きたい
などの設定をパッケージングし
簡単に再利用できる機能。
CircleCIにて用意されている。
なくても自分で作成して登録可能。
CircleCI Orbs②
Parametersの使用
コマンドのスクリプト化
- コマンドを複数まとめて書かず、
スクリプト化して呼び出す
- 右の場合、エラー発生時原因箇所が特定できない
ジョブ実行時間を短縮する工夫
- テストの並列実行
- 依存関係の再利用
テストの並列実行
テストコードをCircleCIでファイル分割して並列実行してくれる
並列実行するコンテナ数を指定
分割方法
依存関係の再利用
- Version 2.1以上
- 前回のビルドによるNpm モジュール
などの依存関係の設定をキャッシュし、
再利用できる(保存期間15日)
→ビルド時間が短くなる
※checksumで指定したファイルに変更があるとキャッシュは
再作成される(この場合package-lock.json)
キャッシュがなければ作る
キャッシュがあれば使う
この処理がスキップできる
その他便利機能
ジョブの承認機能
Web-uiで承認するまでパイプラインを一時停止
チャットによるサポート
リアルタイム対応
SSHによるデバッグ
コンテナに入ってデバッグ
まとめ
- CI/CDを導入すると開発サイクルの効率が上がる(DevOps)
- 手動のルーティン作業は自動化でミスをなくすことができる
- CircleCIにはdocker imageやorbsなど便利機能が用意されているので活用
ありがとうございました

More Related Content

Featured

ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...Palo Alto Software
 
9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free VacationWeekdone.com
 
I Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from PrinceI Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from PrinceEmpowered Presentations
 
How to Map Your Future
How to Map Your FutureHow to Map Your Future
How to Map Your FutureSlideShop.com
 

Featured (20)

ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
 
9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation
 
I Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from PrinceI Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from Prince
 
How to Map Your Future
How to Map Your FutureHow to Map Your Future
How to Map Your Future
 

Iret tech labo#5 CircleCIで始めるCI/CD導入の基本と導入事例の紹介