Unable to build project with Jenkins - gradlew issue

I’ve been trying to get an Ionic Android app working with Jenkins, and almost made it (with much struggle along the way), and now I’m stuck on the final ionic build --android step. Works fine locally of course and ALSO I can run just the above build command fine from CL on the Jenkins box.

The issue happens when Jenkins runs the command, it looks for gradlew in the Android SDK folder on the machine instead of in platforms/android/gradlew as it does in the cases I mentioned above. To wit (redacted company/client names from paths):

LOCAL:

Running command: /Users/xxxx/Sites/xxxx/xxxx/platforms/android/cordova/build 
ANDROID_HOME=/Users/xxxx/Library/Android/sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/xxxx/Sites/xxxx/xxxx/platforms/android/gradlew cdvBuildDebug -b /Users/xxxx/Sites/xxxx/xxxx/platforms/android/build.gradle -Dorg.gradle.daemon=true

JENKINS BOX DIRECT CL:

Running command:/Users/xxxx/.jenkins/jobs/xxxx/workspace/platforms/android/cordova/build 
ANDROID_HOME=/Users/xxxx/Library/Android/sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/xxxx/.jenkins/jobs/xxxx/workspace/platforms/android/gradlew cdvBuildDebug -b /Users/xxxx/Sites/xxxx/xxxx/platforms/android/build.gradle -Dorg.gradle.daemon=true

JENKINS TASK:

Running command: "/Users/xxxx/.jenkins/jobs/xxxx/workspace/platforms/android/cordova/build" 
ANDROID_HOME=/Users/xxxx/.jenkins/tools/android-sdk/platform-tools
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
e[1me[31m/Users/xxxx/.jenkins/jobs/xxxx/workspace/platforms/android/cordova/node_modules/q/q.js:126
                throw e;
                      ^
Error: Could not find gradle wrapper within android sdk. Might need to update your Android SDK.
Looked here: /Users/xxxx/.jenkins/tools/android-sdk/platform-tools/tools/templates/gradle/wrapper

I’m not an expert with Jenkins or Android. I’m seeing that the Jenkins initiated task is using a different sdk and jdk than the CL one, but for whatever reason the build decides to look for gradle wherever it wants and it only happens in this case.

Any help? I’m writing a piece on developing this app soon and this would be a great help to include because I haven’t been able to find any answers.