2013-11-15 19 views
22

我正在爲我的iOS應用程序設置CI,並且遇到一些問題。Bot(Xcode 5 CI)的自定義觸發腳本

  • 哪裏是在Bot上查找文檔的好地方?我見過的Xcode 幫助,但無法找到任何很好的例子,還觀看了由 2013會議
  • 如何創建一個自定義觸發腳本的CI視頻,所以每次開發商 提交他們的代碼就會自動觸發機器人。
  • 只有當測試成功通過 機器人時,我如何合併代碼才能掌握?

這裏就是我找到約觸發器腳本信息 https://help.apple.com/xcode/mac/1.0/#apdE6540C63-ADB5-4B07-89B7-6223EC40B59C

例值示與每個設置。計劃:選擇手動,定期運行 ,在新提交中或在觸發器腳本上運行。

謝謝!

回答

0

在bot的方案中,創建一個分析測試結果的構建腳本。

測試結果將在這裏位於:

/Library/Server/Xcode/Data/BotRuns/Latest/output/xcodebuild_result.bundle/Info.plist 

一旦你驗證測試通過在plist中,您可以合併到主。

然後創建一個機器人,只有當有人推掌握集成。我相信編輯機器人的日程安排有一個選項,用於輪詢回購變更。確保bot是由當前在主控上的Xcode項目創建的。

第一個機器人將需要創建時的Xcode是在測試分支,你會創建。

2

有蘋果開發者網站提供的如何設置你的CI構建詳細的解釋上可用的Continuous Integration Guide。它缺少關於觸發器腳本的細節。

對於最好的文檔在OSX服務器腳本本身找到。此處Apple使用的術語「觸發器腳本」指的是Git中的post-receive hooks。可以將Git事件掛鉤添加到任何Git存儲庫的.git/hooks子目錄中,以執行操作以響應包含它們的Git存儲庫上的事件。

要查看示例後收到掛鉤,特別是「踢」的Xcode的服務運行CI構建,創建主機您的Xcode構建服務的服務器上託管Git倉庫。默認情況下,添加到Xcode服務器的Git存儲庫會自動創建後接收掛鉤。在這種情況下它是一個Ruby腳本POST s至http://localhost/xcs/kick-commit-botsrepositorybranch設置到存儲庫的URL(因爲它是在Xcode服務配置)表單字段和分支分別拉哪個。

因此,請按照Xcode持續集成指南中列出的步驟創建託管存儲庫,然後在Xcode服務器上查看/Library/Server/Xcode/Repositories/git/<your project>.git/hooks/post-receive的內容。如果您將Git項目託管在其他地方(例如BitBucket,GitHub或本地網絡上的一個Linux機器),您可以使用該文件作爲指導,以您選擇的腳本語言創建自己的post-receive hook。

對於那些沒有自己的生成服務器上創建一個託管回購的選擇誰舉個例子:

#!/usr/bin/env ruby 

## 
# Copyright (c) 2014 Apple Inc. All Rights Reserved. 
# 
# IMPORTANT NOTE: This file is licensed only for use on Apple-branded 
# computers and is subject to the terms and conditions of the Apple Software 
# License Agreement accompanying the package this file is a part of. 
# You may not port this file to another platform without Apple's written consent. 
# 
# IMPORTANT NOTE: This file is licensed only for use with the Wiki Server feature 
# of the Apple Software and is subject to the terms and conditions of the Apple 
# Software License Agreement accompanying the package this file is part of. 
## 

# fill in the exact URL to your repository, as entered in your OS X Server configuration 
$repository_url = "file:///git/python-lrparser.git" 
$repository_mode = "git" 

# fill in the hostname of your OS X Server machine; this must be accessible by the server 
# on which your repository is hosted; you may use "localhost" for the local machine 
#server_host = "server.example.com" 
$server_host = "localhost" 


########################################## 
## DO NOT EDIT BELOW THIS LINE 
########################################## 

require 'net/http' 

def kick(branch) 
    theURL = URI("http://#{$server_host}/xcs/kick-commit-bots") 
    if branch.nil? 
    Net::HTTP.post_form(theURL, 'repository' => $repository_url) 
    else 
    Net::HTTP.post_form(theURL, 'repository' => $repository_url, 'branch' => branch) 
    end 
end 

if __FILE__ == $0 
    # determine what branch this is a push to, if possible 
    branches = [] 

    if $repository_mode == "git" 
    $stdin.each_line do |line| 
     oldrev, newrev, ref = line.strip.split 
     if ref =~ %r{^refs/heads/(.+)$} 
     branches.push($~[1]) 
     end 
    end 
    elsif $repository_mode == "svn" and ARGV.length >= 2 
    repository = ARGV[0] 
    revision = ARGV[1] 
    modifiedDirs = `svnlook dirs-changed -r #{revision} #{repository}`.lines.map { |line| line.chomp } 
    modifiedDirs.each do |d| 
     if d =~ %r{branches/([^/]+)} 
     branches.push($~[1]) 
     end 
    end 
    end 

    # if we have no branch information, just kick generically 
    puts "Notifying OS X Server..." 
    if branches.empty? 
    kick(nil) 
    else 
    # otherwise, do a targeted kick for each relevant branch 
    branches.each do |branch| 
     kick(branch) 
    end 
    end 
end