I have a problem with Xcode bots. I'm able to compile, test and archive my project, but I would like to use external tool that checks if I did code review for last commits. I would like to be able to abort build if there is no code review. I tried to add exit 1
or exit 0
in pre-build
script but it just ends given script not whole building process. So my question is how I can abort Xcode bot build (integration)?
Technically, it is possible. You can cancel an integration, which immediately aborts it. It's a very similar process to triggering an integration from the command line, which I described here , but you would first need to find out the _id
of the integration by calling using the endpoint /xcode/api/bots/BOT_ID/integrations
and the first integration should be the latest. Copy the _id
and then call a POST on /xcode/api/integrations/INTEGRATION_ID/cancel
, which will cancel the integration.
I use all these APIs in my tool Buildasaur , so check out the source code for more details.
Thanks to czechboy's answer, here is a solution for copy & paste friends. Use something like this as pre-integration script:
#!/bin/sh
# something returning an error code like:
${XCS_PRIMARY_REPO_DIR}/customPreIntegrationConfiguration.sh
# if script exits with error code 1:
if (( $? )); then
echo "canceling integration ${XCS_INTEGRATION_ID}..."
curl -kX POST "https://localhost:20343/api/integrations/${XCS_INTEGRATION_ID}/cancel"
fi
$?
checks the exit code of the last command, in this case the script. If you are using a pipe somewhere, it can be necessary to use set -o pipefail
to return 1 if only one pipe component returns 1.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.