Continuous integration Bot的自定义触发器脚本(Xcode 5 CI)

Continuous integration Bot的自定义触发器脚本(Xcode 5 CI),continuous-integration,xcode5,xcode-bots,Continuous Integration,Xcode5,Xcode Bots,我正在为我的iOS应用程序设置CI,我面临一些问题 在哪里可以找到Bot上的文档?我看过Xcode 帮助但找不到任何好的例子,还观看了来自 2013年会议 如何创建自定义触发器脚本,因此每次开发人员 提交他们的代码,它将自动触发bot 只有当测试成功通过时,我如何将代码合并到master 机器人 在这里我找到了关于触发器脚本的信息 每个设置都显示了示例值。计划:选择运行 手动、定期、在新提交时或在触发脚本上执行 谢谢大家! 在bot的方案中,创建一个分析测试结果的构建后脚本 测试结果将位于

我正在为我的iOS应用程序设置CI,我面临一些问题

  • 在哪里可以找到Bot上的文档?我看过Xcode 帮助但找不到任何好的例子,还观看了来自 2013年会议
  • 如何创建自定义触发器脚本,因此每次开发人员 提交他们的代码,它将自动触发bot
  • 只有当测试成功通过时,我如何将代码合并到master 机器人
在这里我找到了关于触发器脚本的信息

每个设置都显示了示例值。计划:选择运行 手动、定期、在新提交时或在触发脚本上执行


谢谢大家!

在bot的方案中,创建一个分析测试结果的构建后脚本

测试结果将位于此处:

/Library/Server/Xcode/Data/BotRuns/Latest/output/xcodebuild_result.bundle/Info.plist
一旦验证测试通过了该plist,就可以合并到master中

然后创建一个机器人,只有当有人推到主机时,它才会集成。我相信编辑机器人的时间表可以选择轮询回购协议的变更。确保bot是由当前在master上的Xcode项目创建的

当Xcode位于您要创建的测试分支上时,需要创建第一个bot。

Apple开发者网站上提供了一个详细的说明,说明如何设置CI构建。但是,它缺乏关于触发器脚本的详细信息

为此,最好的文档可以在OSX服务器脚本中找到。Apple在这里使用的术语“触发器脚本”是指Git中的后期接收挂钩。Git事件挂钩可以添加到任何Git存储库的.Git/hooks子目录中,以对包含它们的Git存储库上的事件执行响应操作

要查看专门“踢”Xcode服务以运行CI构建的示例post接收钩子,请在托管Xcode构建服务的服务器上创建托管Git存储库。默认情况下,添加到Xcode服务器的Git存储库将自动创建一个post接收挂钩。在本例中,它是一个Ruby脚本,它
POST
s to
http://localhost/xcs/kick-commit-bots
存储库
分支
表单字段分别设置为存储库的URL(在Xcode服务中配置)和要提取的分支

因此,按照Xcode连续集成指南中概述的步骤创建托管存储库,然后在Xcode服务器上查看
/Library/Server/Xcode/Repositories/git/.git/hooks/post receive
的内容。如果您将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