Exec of 'gradle' from gradle fails on 2.7, works on 2.6

I have a complex project that actually creates a new project dynamically and runs gradle on it. (The code is fairly old so there may be a better way now.)

task buildThing(type:Exec) {
    workingDir = buildDir
    if(isWindows) {
        executable = System.getenv('COMSPEC')
        args = ['/c', 'call', 'gradle', 'allRelease']
    } else {
        executable = 'gradle'
        args = ['allRelease']
    // Override SDK folder for building this project (we are bootstrapping the SDK itself)
    environment('PRIVATE_SDK', stagingDir)

So when I run with gradle 2.7 on OS X I get “command ‘gradle’ not found” when it gets to this task.
With gradle 2.6 it works.
My first guess is that the environment is different and I’ve lost the ~/bin (where I have gradle symlinked to the real gradle executable) from the $PATH ?

Well it seems I can’t reproduce this. It may have been related to a long-running gradle daemon which was killed and restarted as part of me moving back to 2.6. Perhaps the daemon environment was a bit messed up.