2

We ran out of disk space on the CI server (!) and have decided to clean up some older integrations. However, I can find no way to multi-select integrations in the Report navigator. Is this possible?

xcode bot integrations

(I suppose there might be a way via the unofficial API but I'd rather not)

Jedidja
  • 16,610
  • 17
  • 73
  • 112

2 Answers2

5

As far as I know, it's only possible to delete integrations one by one. You can do so by first fetching a list of bots (GET /api/bots), finding your bot's _id (let's call it BOT_ID) and then getting the list of its integrations (GET /api/bots/BOT_ID/integrations) and just collecting their ids and revs.

Then, you can iterate and call for each integration DELETE /api/integrations/INTEGRATION_ID/REV_ID.

The way you call each of these APIs is e.g. curl -k -u USER:PASS https://localhost:20343/api/..., so to get all bots just run curl -k -u USER:PASS https://localhost:20343/api/bots

See more details for yourself in this file: /Applications/Xcode.app/Contents/Developer/usr/share/xcs/xcsd/routes/routes_integration.js

If you want to know more about XCS internals, I built a Swift SDK: https://github.com/czechboy0/XcodeServerSDK and wrote about the internals in http://honzadvorsky.com/articles/2015-05-04-under-the-hood-of-xcode-server/

czechboy
  • 899
  • 7
  • 15
  • I have a [gist](https://gist.github.com/shpakovski/f175a8164e60ab79823dcbf970a51d4c) with a working solution. It will remove all integrations if this is what you need. – Vadim Dec 03 '18 at 19:34
1

I had the disk space running out issue as well. I initially thought the integrations were to blame and deleted most of them manually but the disk space reclaimed was not significant to what was consumed. One would think that deleting all integrations should reclaim disk space to a point as if no integration was ever run. But that did not happen after deleting the integrations. Then while looking at the Xcode Server internals based on ideas got from reading Honza's blog (czechboy from above comment) I found out the disk space occupied by

/Library/Developer/XcodeServer/Integration/Caches was the main culprit.

Deleting it I was able to reclaim the entire disk space to the point as if no integration was ever run on the Xcode Server. The folders in there are recreated as you run bots and add new bots. Deleting bots however does not seem to delete the corresponding cache folder. In our case we create bots for any branch that requires builds to be made. Over time that folder did end up occupying the largest chunk of disk space.

Our current solution

  • python script to call the Xcode Server api to delete all integrations. The integration products are all backed up so keeping the individual integrations are of not much value.
  • bash script to delete the caches folder.

Both are run manually as of now. Later maybe we will run it on a schedule of once every couple of weeks.

Honza has done a great job taking apart the Xcode Server. His blog was the most useful read while I was setting things up. Make sure to read his blog in entirety. Its the kind of technical info that you would expect from the dev team at Apple working on Xcode Server however the lack of documentation from Apple is apalling.

NSIntegerMax
  • 542
  • 2
  • 5