Jul 15, 2020

AWS CodeBuild Test Reports for Gradle builds

Although AWS documentation has instructions for adding Test Reports for a maven build they currently lack instructions for a gradle build.

You can find the maven instructions here: https://aws.amazon.com/blogs/devops/test-reports-with-aws-codebuild/

Assuming you have your gradle wrapper in your code commit repository, you just need to update two sections in your buildspec.yml

First, update your buildspec.yml to call the gradlew test by changing the “phases -> builds -> commands” to “bash ./gradlew test”.

Second, update the buildspec.yml to where gradle stores the test reports by changing “reports -> ReportGroupName -> base-directory” to “build/test-results”.

Here is an example of a buildspec.yml with the updates.

version: 0.2
phases:
  build:
    commands:
      - bash ./gradlew test
reports: #New
  TestReports: # CodeBuild will create a report group called "TestReports".
    files: #Store all of the files
      - '**/*'
    base-directory: 'build/test-results' # Location of the reports
cache:
  paths:
    - '/root/.gradle/**/*'

About the Author

Scott Bock profile.

Scott Bock

Principal Technologist

Scott is a Senior Software Engineer with over 12 years of experience using Java, and 5 years experience in technical leadership positions. His strengths include troubleshooting and problem solving abilities, excellent repertoire with customers and management, and verbal and written communication. He develops code across the entire technology stack including database, application, and user interface.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Blog Posts
Rewriting files in Google Cloud Storage
Rewriting Files in GCP Note: even though this code is in Python, this should be the same idea in JavaScript, Go, etc. I wrote the following to copy a file from one Google Cloud Storage […]
Interpreting Spatial Data in the Age of COVID-19
As 2020 has come to an end, many are eager to leave the mess of COVID-19 behind with the new year and gain a fresh start. Unfortunately, new cases are still soaring across the United […]
Building a Better Mousetrap
Recently, my daughter (age 6) was into building “mousetraps” out of shoe boxes. These were more or less comfortable cardboard mouse houses complete with beds, rooms, everything a mouse could want or need and not […]
ARM Wrestling Its Way Into Mainstream Software Development
Nearly all smart phones have been running ARM-based processors for years. They provide superior power for the amount of power consumed, and thus extend battery life. With Apple’s recent release of the Apple Silicon M1 […]