CI ビルドをセットアップする方法の詳細な説明を提供する、Apple 開発者 Web サイトで利用可能な継続的インテグレーション ガイドがあります。ただし、トリガー スクリプトの詳細はありません。
そのための最適なドキュメントは、OSX Server スクリプト自体にあります。ここで Apple が使用する「トリガー スクリプト」という用語は、Git の post-receive フックを指します。Git イベント フックを任意の Git リポジトリの .git/hooks サブディレクトリに追加して、それらを含む Git リポジトリのイベントに応答してアクションを実行できます。
CI ビルドを実行するために Xcode サービスを具体的に「キック」する post-receive フックの例を確認するには、Xcode ビルド サービスをホストするサーバー上にホストされた Git リポジトリを作成します。デフォルトでは、Xcode サーバーに追加された Git リポジトリーには、post-receive フックが自動的に作成されます。この場合、(Xcode サービスで構成されているように) リポジトリの URL に設定されたフィールドとフォーム フィールドを使用する Ruby スクリプトと、POST
それぞれプルするブランチです。http://localhost/xcs/kick-commit-bots
repository
branch
そのため、Xcode 継続的インテグレーション ガイドで説明されている手順に従ってホストされたリポジトリを作成/Library/Server/Xcode/Repositories/git/<your project>.git/hooks/post-receive
し、Xcode サーバーでコンテンツを表示します。Git プロジェクトを別の場所 (例: BitBucket、GitHub、またはローカル ネットワーク上の Linux ボックス) でホストしている場合、選択したスクリプト言語で独自の post-receive フックを作成するときに、このファイルをガイドとして使用できます。
ビルド サーバーでホストされたリポジトリを作成するオプションがない場合の例:
#!/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