# 別再讓出版本綁架你的時間!CI & CD - Unity X Jenkins 2021 TGDF 台北遊戲開發者論壇 [共筆筆記索引](/HksczuLpu) [官網連結](https://2021.tgdf.tw/speakers/26) 講者:Cliff Lee CL # Outline - 什麼是 CI & CD - Jenkins - Unity x Jenkins - Unity Project Builder - Jenkins Blue Ocean - 最小可行 CI # 什麼是 CI & CD? ## 觀察到的問題 - 出版本花的時間很長(30 min. ~ 1 hr.) - 流程 - 在 mac 上取得最新的 code - unity build 產生 xcode 專案 - 人工看進度 - xcode 改參數 - 手動改參數 - 上傳 ## 接觸 CI 的契機 - 出版本浪費人力資源 - 應該要自動化處理 - 嘗試導入 Jenkins # CI & CD 的分類 - 持續整合 - 持續交付 - 持續部屬 # CI & CD 的好處 - 加速迭代節奏 - 降低資安風險 - 避免人為疏失 - 增進遊戲品質 - 及早發現錯誤 # Jenkins - open source automation server - 1500+ plugins - popular (200000+ install) ## 其他選項 - Github Actions - Travis CI - Gitlab CI/CD # 架設 Jenkins [official document](https://www.jenkins.io/doc/book/installing/) # unity x jenkins ## 環境 - master 和 agent 放在同一台 ## 最小可行 CI - Initialize - Build - Deploy ## Unity Command Line [official document](https://docs.unity3d.com/Manual/CommandLineArguments.html) ```shell= $UNITY_PATH \ -projectPath $UNITY_PROJECT_DIR \ -buildTarget $BUILD_TARGET \ -executeMethod $UNITY_BUILD_METHOD \ -logFile - \ # log to stdout -quit -batchmode -nographics ``` # Unity Project Builder - `ProjectBuilder` 要放在 Editor 資料夾內 - 給外部執行的函式,要設為 public class 內的 public static - 回傳非 0 表示建置失敗 # Jenkins Job - Free-style - 流程存在 Jenkins 內 - 不同流程要分成不同 job - 入門較容易理解 - Pipeline - 可以版控 - Multibranch Pipeline - 可以針對不同 branch 做不一樣的流程 - 可以平行化 # Pipeline script - 以 Groovy 撰寫 - Scripted pipeline - 比較彈性但不易上手 - Declarative pipeline - 比較容易理解、撰寫 # Jenkins Blud Ocean - 視覺化 pipeline - 提供 pipeline 編輯器 - 相容 free-style job - 還不支援 SVN 專案 # Example ## Initialize > 準備好建置環境,確認沒有會影響到建置的資料 - 進到專案目錄 - `git clean` 清掉不需要的東西 - `Library` 留下來節省時間 :::info Jenkins 內建變數 [reference](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables) - `WORKSPACE` - `JOB_NAME` - `BUILD_NUMBER` - `BUILD_URL` ::: ## Build - 新增區域環境變數 - 下 build 的指令 :::warning 字串內插記得要用雙引號 ::: ## Deploy > 取得 artifacts - `archiveArtifact` # Next - Build Notifier - BUild 完之後發訊息通知 - test - test report - code analysis # 總結 - 將繁雜步驟自動化,做更有價值的事情 ###### tags: `2021TGDF` `台北遊戲開發者論壇` `共筆筆記`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up