I'm trying to set up my first Android project to build on Jenkins.
I'm running Jenkins 1.6.2 with version 1.24 of the Gradle plugin. Running on Windows 7 Professional SP1.
I've installed Android Studio and the Java7 JDK on my build machine, and a checked-out version of the software builds just fine, through Android Studio or when running gradlew.bat from the command line. But I can't get the Invoke Gradle script build task to work, within my Jenkins job.
There is a pair of radio buttons, on the configure project page:
If I select "Invoke Gradle", I'm asked to select a "Gradle Version", which is something I setup in Configure System.
I created a gradle installation with GRADLE_HOME set to "D:\Program Files\Android Studio\gradle\gradle-2.2.1". That gives me a warning that "D:\Program Files\Android Studio\gradle\gradle-2.2.1 is not a directory on the Jenkins master...."
And when I run a build, I get an error "Can't retrieve the Gradle executable".
Which is probably related to the gradle plugin complaining about the directory. But the directory is correct. I've tried it with '/' instead of '\', and it made no difference.
Since that didn't work, I tried the alternative, "Use Gradle Wrapper". There's a checkbox: "From Root Build Script Dir". Whether I check it, or not, I get "java.lang.IllegalArgumentException: android.compileSdkVersion is missing!"
I've set both JAVA_HOME and ANDROID_HOME, so that's not the issue.
Any ideas?
As a followup, I delete the gradle task, and added an Execute Windows batch command task:
SET ANDROID_HOME=d:\Program Files\Android\sdk
SET JAVA_HOME=d:\Program Files\Java\jdk1.7.0_79
.\gradlew.bat clean
When I run that, I still get that error.
But when I run those commands from a command line on the build machine, they work just fine.
What could be different, when running gradlew.bat from Jenkins, than when running it from the command line? The Jenkins service is configured to use the same user as I'm logged in as, when I'm running from the command line. I've tried explicitly setting each and every environment variable I have set in the command line, in the Jenkins task, and I'm still seeing the error.
Any ideas?
Located in the project/module directory of the project this Gradle script is where all the dependencies are defined and where the SDK versions are declared.
Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project. Click Build > Make Project to test your build file by building your project and address any errors you find.
Your local.properties file must contain: sdk.dir="path to your android sdk"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With