2013-11-15 12 views
22

Sto lavorando alla configurazione di CI per la mia applicazione iOS e sto affrontando alcuni problemi.Custom Trigger Script per Bot (Xcode 5 CI)

  • Dove è un buon posto per trovare documenti su Bot? Ho visto l'aiuto Xcode ma posso trovare qualsiasi buon esempio, anche visto il video CI da 2013 conferenza
  • Come faccio a creare un trigger di script personalizzato, in modo che ogni volta che uno sviluppatore impegna il loro codice che farà scattare automaticamente il bot .
  • Come si unisce il codice al master solo se Test supera correttamente il bot ?

Qui è dove ho trovato informazioni sugli script di trigger https://help.apple.com/xcode/mac/1.0/#apdE6540C63-ADB5-4B07-89B7-6223EC40B59C

valori di esempio sono mostrati con ogni impostazione. Pianificazione: scegliere di eseguire manualmente , periodicamente, su nuovi commit o sugli script di trigger .

Grazie!

risposta

0

Nello schema del bot, creare uno script di post build che analizzi i risultati del test.

I risultati del test saranno situati qui:

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

Una volta verificato che i test passano in quel plist, è possibile unire in master.

Quindi creare un bot che si integra solo quando qualcuno spinge al master. Credo che la modifica della pianificazione del bot abbia un'opzione per il polling di un repository per le modifiche. Assicurati che il bot sia creato da un progetto Xcode che è attualmente su master.

Il primo bot deve essere creato quando Xcode si trova sul ramo di test che si desidera creare.

2

C'è uno Continuous Integration Guide disponibile sul sito Web degli sviluppatori Apple che fornisce spiegazioni dettagliate su come configurare le build CI. Manca però i dettagli sugli script di trigger.

Per questo la documentazione migliore si trova negli script OSX Server stessi. Il termine "script di trigger" usato qui da Apple si riferisce ai ganci post-ricezione in Git. Gli hook di eventi Git possono essere aggiunti alla sottodirectory .git/hooks di qualsiasi repository Git per eseguire azioni in risposta agli eventi nel repository Git che li contiene.

Per vedere un esempio di hook di post-ricezione che specificamente "prende a calci" un servizio Xcode per eseguire build CI, creare un repository Git ospitato sul server che ospita il servizio di build Xcode. Per impostazione predefinita, i repository Git aggiunti a un server Xcode avranno un hook post-ricezione creato automaticamente. In questo caso si tratta di uno script Ruby che POST sa http://localhost/xcs/kick-commit-bots con repository e branch campi modulo impostati sull'URL del repository (come è configurato nel servizio Xcode) e sul ramo da prelevare rispettivamente.

Quindi, creare un repository ospitato seguendo i passaggi descritti nella Guida all'integrazione continua di Xcode e quindi visualizzare i contenuti di /Library/Server/Xcode/Repositories/git/<your project>.git/hooks/post-receive sul server Xcode. Se ospiti i tuoi progetti Git altrove (ad es.BitBucket, GitHub o una casella Linux sulla rete locale) è possibile utilizzare questo file come guida per creare il proprio hook di post-ricezione nel linguaggio di scelta dello script.

un esempio per coloro che non hanno la possibilità di creare un repo ospitato sul proprio server di generazione:

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