1

I am trying to run Continuous Integration for iOS with an Xcode server running validation tests against Gerrit.

In order to get Xcode to pull from the gerrit server I had to upgrade it's libgit2.dylib to version 0.21.5

I downloaded it from https://codeload.github.com/libgit2/libgit2/zip/v0.21.5

Anyone have suggestion on how to get gerrit to trigger Xcode builds of particular branches?

MongoTheGeek
  • 294
  • 1
  • 10

2 Answers2

1

An easy way is to create an Xcode bot that will perform the build. You can have the bot set to poll Gerrit’s repository periodically for the desired hook (most likely ‘commit’).

http://bjmiller.me/post/72937258798/continuous-integration-with-xcode-5-xctest-os-x is a good step-by-step guide on setting up an Xcode bot, but keep in mind that you are using Gerrit as the git repository.

With an Xcode bot created, you could also create a Gerrit hook that triggers a build in the same manner that an Xcode git repository would: Custom Trigger Scripts for Bot (Xcode 5 CI)

Community
  • 1
  • 1
0

The whole thing is complicated but...

Set up a Jenkins jobs that is triggered by Gerrit (My entire goal is to bring iOS tools to parity with Android)

When that job runs it performs the following shell script. This can be improved by polling the server first and parsing out the BOT_HASH but I just did it by hand. The bot is set to integrate manually.

curl -kg -X POST "https://[XCODE_SERVER]:20343/api/bots/[BOT_HASH]/integrations/"

The bot has the following script as a pre-integration step

cd [PROJECT]
ssh -p 29418 xcode@[GERRIT_SERVER] 'gerrit query label:Verified=0 project:[PROJECT]  status: open limit:1 --current-patch-set' >/tmp/junk.txt
export commit=`grep revision: /tmp/junk.txt | grep -oE '[^ ]+$'`
export ref=`grep ref: /tmp/junk.txt | grep -oE '[^ ]+$'`
git fetch "http://[GERRIT_SERVER]:8081/[PROJECT]" $ref && git checkout FETCH_HEAD
git checkout -b $commit
ssh -p 29418 xcode@[GERRIT_SERVER] 'gerrit review -p [PROJECT] -m "Starting Test" '$commit

This checks the gerrit server for the most recent update to the project that hasn't been verified. It might not get the right one, but eventually they will all be be checked. It then updates the git repository to no longer point to the commit at the head but at the one we want to check. Finally it posts a comment for users so they know it is being looked at.

This relies on a user Xcode existing on the gerrit repo with proper auth's. You can inline usernames and passwords, or you can set up the ssh key from _xcsbuildd.

The success script looks like

export commit=`grep revision: /tmp/junk.txt | grep -oE '[^ ]+$'`
ssh -p 29418 xcode@[GERRIT_SERVER] 'gerrit review -p [PROJECT] -m "Test from the script  xcbot://[XCODE_SERVER]/botID/'$XCS_BOT_ID'/integrationID/'$XCS_INTEGRATION_TINY_ID'" --verified +1 '$commit

This marks it as verified and posts a link that leads directly to the integration. The link is clickable in email but not on the webpage.

The failure looks like this

export commit=`grep revision: /tmp/junk.txt | grep -oE '[^ ]+$'`
ssh -p 29418 xcode@[GERRIT_SERVER] 'gerrit review -p [PROJECT] -m "Test from the script  xcbot://[XCODE_SERVER]/botID/'$XCS_BOT_ID'/integrationID/'$XCS_INTEGRATION_TINY_ID'" --verified -1 '$commit

It is up to you what you consider success or failure. Currently I succeed on warnings and success and fail on build errors and test failures.

To get it to recheck, remove the vote and manually trigger the bot.

MongoTheGeek
  • 294
  • 1
  • 10