22

iOS アプリケーションの CI の設定に取り組んでいますが、いくつかの問題に直面しています。

  • ボットに関するドキュメントを見つけるのに適した場所はどこですか? Xcode のヘルプを見たことがありますが、良い例が見つかりません。2013 年のカンファレンスの CI ビデオも見ました。
  • カスタム トリガー スクリプトを作成して、開発者がコードをコミットするたびにボットが自動的にトリガーされるようにするにはどうすればよいですか。
  • Test がボットを正常に通過した場合にのみ、コードを master にマージするにはどうすればよいですか?

トリガースクリプトに関する情報を見つけた場所は次のとおりです https://help.apple.com/xcode/mac/1.0/#apdE6540C63-ADB5-4B07-89B7-6223EC40B59C

各設定値の例を示します。スケジュール: 手動で、定期的に、新しいコミットで、またはトリガー スクリプトで実行するように選択します。

ありがとうございました!

4

2 に答える 2

3

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-botsrepositorybranch

そのため、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
于 2014-08-19T22:18:08.093 に答える
0

ボットのスキームで、テスト結果を解析するビルド後のスクリプトを作成します。

テスト結果は次の場所にあります。

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

その plist でテストがパスすることを確認したら、master にマージできます。

次に、誰かがマスターにプッシュしたときにのみ統合するボットを作成します。ボットのスケジュールを編集すると、リポジトリに変更をポーリングするオプションがあると思います。現在マスター上にある Xcode プロジェクトによってボットが作成されていることを確認してください。

最初のボットは、Xcode が作成するテスト ブランチにあるときに作成する必要があります。

于 2014-03-21T04:55:00.903 に答える