Search⌘ K

Enhancements to Buildspec YAML File

Understand how to enhance your buildspec YAML file to create comprehensive test reports using AWS CodeBuild. Learn the key sections such as reports, files, base-directory, and discard-path to organize test results effectively. Discover IAM role permissions required to enable report group creation and upload test artifacts. This lesson helps ensure your CI/CD pipeline captures and manages test results accurately for better visibility in your development process.

Proper documentation of test results and related trends is essential for DevOps deployment. AWS CodeBuild allows us to generate test reports for the tests that run alongside our build. It also provides visibility to code coverage in our project. A developer needs to make a few changes to the build specification file to create these test reports.

The reports section

YAML
reports:
<report-group-name> or arn:
files:
- <file-location>
file-format: <format-type>
base-directory: <top-level-directory>
discard-paths: yes|no

A build specification file commonly contains version, phase, and artifact sections. The reports depends on the commands specified in the build phase. The build phase must run the tests and generate raw data containing test results. To create test reports from this raw data, we need to include a new section named reports. This section starts by specifying the name of the report group. If a report group does not exist, CodeBuild will create one on the fly. But as a best practice, creating a report group and using its arn as the report group’s name is recommended.

If a pre-existing report group name is specified, CodeBuild will reuse that report group ...