Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using script to fire Xcode bot

Is there a way to manually fire existing Xcode bots using shell scripts? I have a manual bot and I'd like to fire it based on certain custom logic criteria.

like image 242
Tarek Avatar asked Nov 30 '22 17:11

Tarek


1 Answers

Yes.

You'll need to do a couple of things: Firstly, I'm going to call your Xcode Server's IP address XCS_IP, usually localhost if you're on the machine where Xcode Server's running.

  • Find out the ID of the bot: in Terminal, run curl -k "https://XCS_IP:20343/api/bots". Copy the output to some editor and find the value for key _id for your bot, will be something like 6b3de48352a8126ce7e08ecf85093613. Let's call it BOT_ID.

  • Trigger an integration by running curl -k -X POST -u "username:password" "https://XCS_IP:20343/api/bots/BOT_ID/integrations" -i

Where username and password are credentials of a user that is allowed to create bots on the server, an admin will do.

If you're interested in more details, I have an app in Swift that uses that API and many more: https://github.com/czechboy0/Buildasaur/blob/master/BuildaCIServer/XcodeServer.swift#L324

And checkout my article on how to find Xcode Server's API "documentation": http://honzadvorsky.com/blog/2015/5/4/under-the-hood-of-xcode-server.

TL;DR? On your Mac, look at /Applications/Xcode.app/Contents/Developer/usr/share/xcs/xcsd/routes/routes.js, where you can find the available APIs.

Hope this helped.

like image 196
czechboy Avatar answered Dec 10 '22 23:12

czechboy