Running a Gradle Build in Bamboo
Gradle is an excellent build tool for your projects. I’m really enjoying using it for my new projects, and I love having a full scripting language (Groovy) to write my builds in.
The one issue I had was integrating gradle into my continuous integration tool. I’m using the hosted Atlassian suite, so my continuous integration environment is Bamboo. However, Bamboo doesn’t natively support gradle.
Luckily, gradle has a great feature which allows you to run gradle builds on machines without gradle installed: gradlew. And, Bamboo has a feature run any script you like for builds. Below are instructions on how to configure a Bamboo build to run gradlew.
Steps to Create a Gradle Bamboo Build
Create gradle wrapper task in your gradle build file
task createWrapper(type: Wrapper) { gradleVersion: '1.0-milestone-3' }Run the task using gradle to create the gradlew scripts and download the jars
gradle createWrapperCheck in the gradlew scripts (gradlew and gradlew.bat) and the gradle directory (
/gradle) to your version control system. Create a new build plan in Bamboo for you project
Use your normal configuration for Plan Details and Source Repository
Update the Builder Section using the following values (make sure to set your working sub directory properly or gradlew will not fine your build.gradle)
Builder: Script Script: ./gradlew Argument: build Working Sub Directory: <your project directory>Setup your test reports directory in the “Where should Bamboo look for the test result files?” section
The build will produce test results: checked Specify custom results directories: **/test-results/*.xmlFinish the rest of the build plan in Bamboo like you normally would
Run the build and you should see the gradlew loading in the log file. In the log you will see something similar to the following:
Downloading http://repo.gradle.org/gradle/distributions/gradle-1.0-milestone-3-bin.zip Unzipping /home/bamboo/.gradle/wrapper/dists/gradle-1.0-milestone-3-bin.zip to /home/bamboo/.gradle/wrapper/dists Set executable permissions for: /home/bamboo/.gradle/wrapper/dists/gradle-1.0-milestone-3/bin/gradle :compileJava Download http://repo1.maven.org/maven2/org/springframework/spring-webmvc/3.0.5.RELEASE/spring-webmvc-3.0.5.RELEASE.pom Download http://repo1.maven.org/maven2/org/springframework/spring-parent/3.0.5.RELEASE/spring-parent-3.0.5.RELEASE.pom Download http://repo1.maven.org/maven2/org/springframework/spring-asm/3.0.5.RELEASE/spring-asm-3.0.5.RELEASE.pom . . .You should also see that all your unit tests have run in the log and be able to see the results in the Test tab of the Bamboo Plan run.
Congratulations, you now have Bamboo set up to run your gradle builds.