Bot的自定义触发器脚本(Xcode 5 CI) [英] Custom Trigger Scripts for Bot (Xcode 5 CI)

查看:131
本文介绍了Bot的自定义触发器脚本(Xcode 5 CI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的iOS应用设置CI,我遇到了一些问题。

I am working on setting up CI for my iOS application and I am facing some issues.


  • 文档在Bot?我看到了Xcode
    帮助,但没有找到任何好的例子,也观看了来自
    2013会议的CI视频

  • 如何创建自定义触发器脚本,每当开发人员
    提交他们的代码时,它会自动触发bot。

  • 如果Test成功通过
    机器人,我如何将代码合并到master? / li>
  • Where is a good place to find documents on Bot? I have seen the Xcode help but cant find any good example, also watched the CI video from 2013 conference
  • How do i create a custom trigger script, so every time a developer commits their code it will automatically trigger the bot.
  • How do I merge the code to master only if Test successfully passes the bot?

这里是我找到有关触发器脚本的信息
https://help.apple.com/xcode/mac/1.0/#apdE6540C63-ADB5-4B07-89B7-6223EC40B59C



Here is where I found info about trigger scripts https://help.apple.com/xcode/mac/1.0/#apdE6540C63-ADB5-4B07-89B7-6223EC40B59C


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

谢谢!

推荐答案

有一个持续集成指南 Apple开发人员网站,其中提供了有关如何设置CI构建的详细说明。然而,它缺少触发器脚本的细节。

There is a Continuous Integration Guide available on the Apple developer website which provides detailed explanations of how to set up your CI builds. It lacks details on trigger scripts however.

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

For that the best documentation is found in the OSX Server scripts themselves. The term "trigger scripts" as used here by Apple refers to post-receive hooks in Git. Git event hooks can be added to the .git/hooks subdirectory of any Git repository to perform actions in response to events on the Git repository which contains them.

示例后接收钩,专门踢Xcode服务以运行CI构建,在托管您的Xcode构建服务的服务器上创建托管的Git存储库。默认情况下,添加到Xcode服务器的Git仓库将自动创建一个post-receive钩子。在这种情况下,它是一个Ruby脚本, POST http:// localhost / xcs / kick-commit-bots 使用 repository 分支将表单字段设置为存储库的URL(因为它是在Xcode服务中配置的)

To see an example post-receive hook which specifically "kicks" an Xcode service to run CI builds, create a hosted Git repository on the server hosting your Xcode build service. By default, Git repositories added to an Xcode server will have a post-receive hook created automatically. In this case it is a Ruby script which POSTs to http://localhost/xcs/kick-commit-bots with repository and branch form fields set to the URL of the repository (as it is configured in the Xcode service) and the branch to pull respectively.

因此,按照Xcode持续集成指南中概述的步骤创建托管存储库,然后查看 / Library / Server / Xcode / Repositories / git /< your project> .git / hooks / post-receive 如果您在其他地方托管您的Git项目(例如BitBucket,GitHub或您的本地网络上的linux框),您可以使用此文件作为指南,在您选择的脚本语言中创建自己的后接收挂钩。

So, create a hosted repository by following the steps outlined in the Xcode Continuous Integration Guide and then view the contents of /Library/Server/Xcode/Repositories/git/<your project>.git/hooks/post-receive on the Xcode server. If you host your Git projects elsewhere (e.g. BitBucket, GitHub or a linux box on your local network) you can use this file as a guide when creating your own post-receive hook in your scripting language of choice.

对于没有在构建服务器上创建托管仓库的选项的示例:

An example for those who don't have the option of creating a hosted repo on their build server:

#!/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

这篇关于Bot的自定义触发器脚本(Xcode 5 CI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆