簡介:
About Continuous Integration in Xcode
Xcode supports a continuous integration workflow through the Xcode service. The Xcode service, available in OS X Server, automates the integration process of building, analyzing, testing, and archiving your app. From your development Mac, you create bots that run on a separate server, where they perform these integrations. Bots help ensure that your product is always in a releasable state—and when there’s a failure, the service notifies you or the person whose code change caused the failure.
配置要求
- 一臺Mac用作Server
- 若干Mac開發(fā)機(jī)
- OS Server軟件
配置步驟
一:OS X Server的配置:
OS X Server app下載鏈接: http://chinamac.dbank.com/c0ju1oq2du
-
安裝好OS X Server后,設(shè)置Xcode Service
2.1 設(shè)置代碼倉庫(Repositories),(我的代碼倉庫是在Github上,我測試的時(shí)候使用SSH連接會失敗,然后使用HTTPS就正常連接)
2.2 設(shè)置Xcode service的權(quán)限(修改Xcode Service Bot的權(quán)限等),分三種:
* 登錄用戶
* 任何用戶
* 部分用戶
2.3 開啟Xcode service.
二:Xcode的配置:
- 在Xcode的Preference -> Accounts -> Add Server ,添加一個(gè)OS X Server ,然后輸入相關(guān)配置.
到這里 ,OS X Server 的Xcoder Service 還有 Xcode都設(shè)置好了.現(xiàn)在可以添加一個(gè)Bot來進(jìn)行自動測試了.
What is Bot:
進(jìn)行自動化測試之前,首先,我們需要?jiǎng)?chuàng)建一個(gè)Bot.
Bot有幾種類型:
- 每次代碼倉庫的commit,都會觸發(fā)
- 定期觸發(fā)
Bot可以在Xcode或者瀏覽器管理頁面上進(jìn)行手動觸發(fā).
在Xcode的Product -> Create Bot來創(chuàng)建一個(gè)Bot.
Why Xcode Service?
- 配置超級簡單.
- OS X Server的UI十分漂亮
- 成本幾乎可以忽略不算.(OS X Server價(jià)格:128軟妹紙)
- 使用簡單,與Xcode無縫連接(操作都在Xcode上可以完成)
- 一條龍服務(wù):靜態(tài)代碼分析,單元測試,持續(xù)集成歸檔.
- OS X Server下的Xcode Service只是一小部分功能,還有wiki(可以建立團(tuán)隊(duì)的知識庫)等其它實(shí)用的功能.
- 并且在WWDC上可以看出,Apple的Xcode team把自動化測試做得越來越好.
- 在Server端,可以同時(shí)測試多臺真機(jī),多臺模擬機(jī).
我們使用的是gitlab做代碼倉庫,在Xcode上配置好OS Server之后,集成的時(shí)候會出現(xiàn)權(quán)限問題:
debug1: Trying private key: /var/empty/.ssh/id_rsa
debug1: Trying private key: /var/empty/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解決方法是將public key還有private key文件分別移到/var/empty/.ssh/id_rsa
, /var/empty/.ssh/id_dsa
目錄下.