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.