iosxcodexcode6xcode-6.2xcode-bots

How to make XCode bot build at specific time of the day if and only if there have been new commits?


Issue:

I am currently running the XCode bot periodically at a specific time of the day. However I only want the bot to make a new build iff there are any new commits in the repo. Each day at that specific time, it should check if there are new commits. In case there have been new commits, then continue with the building process else abort it. Why to run a new build and increment by version number etc, if there have been no changes, right?

What I tried?

I went through the Continuous Integration with XCode 6 WWDC video. It mentions that we can either run the bot periodically or run it after each new commit. I sort of want to combine the two ways. Couldn't find anything on this.

Solution Possible?

I saw there are pre-integration scripts one can run. One way I was thinking was to have my logic of checking if there was a new commit or not in the pre-integration shell script. If there were none, then abort the XCode bot build. How can I abort the build from a script? If there is any other way you know, please do answer/comment.


Solution

  • Not exactly an answer, but found out something that might help. Well, for now it seems nothing can be done to stop the bot once started. However you can choose not to increment the build number, in case there are no new commits from the last time. Depending on what you use the testers/users won't get a new build/notification every time, until there are new commits.

    You can specify scripts to run in your Build Phases. You can put a script after Copy Bundle Resources option, wherein you do a git diff and see if there are any changes. If there are no changes just exit:

    # do not assign the new build number if there is no changes
    DIFF=`git diff`
    if [[ $DIFF == "" ]]; then exit 0; fi
    

    Source: How to adjust the bundle version number in Xcode automatically