На веб-сайте разработчика Apple есть Continuous Integration Guide, который содержит подробные объяснения того, как настроить свои сборки CI. Однако в нем отсутствуют детали скриптов триггеров.
Для этого наилучшая документация находится в скриптах OSX Server. Термин «скрипты запуска», используемый здесь Apple, относится к крюкам после приема в Git. Перехватчики событий Git могут быть добавлены в подкаталог .git/hooks любого репозитория Git для выполнения действий в ответ на события в репозитории Git, который их содержит.
Чтобы увидеть пример отправки сообщения, который специально «запускает» службу Xcode для запуска сборок CI, создайте размещенный репозиторий Git на сервере, на котором размещена ваша служба создания Xcode. По умолчанию репозитории Git, добавленные на сервер Xcode, автоматически создадут крюк после приема. В этом случае это скрипт Ruby, который POST
s - http://localhost/xcs/kick-commit-bots
с repository
и branch
полями формы, заданными для URL-адреса репозитория (как он настроен в службе Xcode), и ветвь для вытягивания соответственно.
Итак, создайте размещенный репозиторий, выполнив шаги, описанные в Руководстве по непрерывной интеграции Xcode, а затем просмотрите содержимое /Library/Server/Xcode/Repositories/git/<your project>.git/hooks/post-receive
на сервере Xcode. Если вы размещаете свои проекты 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