Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RESOLVED] Native or API hooks for nightly UCB builds

Discussion in 'Unity Build Automation' started by nickfourtimes, Jun 5, 2019.

  1. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Heya,

    I've been hoping to set up nightly builds for our UCB projects. Auto-build is overkill, since we often pass half-finished tasks back and forth via Git for verification and collaboration -- auto-building at this point would be unnecessary and often broken, and thus a waste.

    If nightly builds aren't supported in the web interface to UCB (via a similar checkbox to Auto-build), is there some web API we could hook into to set that up? Maybe via a local Jenkins server or even a basic cron job/scheduled task that just calls a method once per day for the projects/builds in question.

    Haven't really been able to find out any information of the sort beyond this five year-old post.
     
  2. victorw

    victorw

    Joined:
    Sep 14, 2016
    Posts:
    459
    You could definitely write a cron job that just runs a simple curl script to achieve that. At the moment there's no API for starting all the builds associated with a given project so you'd have to hit the API once per build target. API documentation for the call you would be interested in is available here and you can find the bearer token in the developer dashboard under Settings -> Cloud Build (for a given project)
     
    nickfourtimes likes this.
  3. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Ah, that's great... and it's probably better to have the fine-grain control anyway, since we've got a variety of build configs and not all of them would need to be run nightly. Thanks for the link!

    Just for reference, I was discussing this with some other folks and we came up with another possible solution. I've set up a branch for our project called "auto-build," along with a UCB config that just sits on that branch and auto-builds whenever it's updated. We only merge our general work into auto-build once per day; therefore UCB becomes a de facto nightly build setup.

    Only problem with that solution is that "build automatically" has been broken on UCB for us for a few months now, but I guess that's something we just need to take up directly with support.
     
  4. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Okay just to follow up, I used the web API to make a script with a number of commands like so:

    curl -X POST -d '{"clean": true, "delay": 30}' -H "Content-Type: application/json" -H "Authorization: Basic {APIKEY}" https://build-api.cloud.unity3d.com/api/v1/orgs/{ORGNAME}/projects/{PROJECTNAME}/buildtargets/{BUILDTARGETNAME}/builds


    (APIKEY, ORGNAME, PROJECTNAME, and BUILDTARGETNAME should all be figured out by the reader).

    We've got one command like this for each of the builds we want to make (three variants on three platforms, so nine builds). I can run the script on a schedule and voila, automated nightly builds, and I didn't even have to make a separate "auto-build" branch in git.
     
    Last edited: Jun 5, 2019
    yuukiandhisaxies and victorw like this.