Search code examples
amazon-web-servicesaws-codepipelineaws-codebuildmaven-surefire-plugin

AWS Code build don't fail if no test files found


My code build build spec yml (version 2.0) report section looks like below

reports:
  surefire-reports:
    files:
      - '**/target/surefire-reports/*.xml'
    discard-paths: false

If there are no report files then code build job fails with the below error

2022-11-11T13:19:32.9976751Z Error in UPLOAD_ARTIFACTS phase: [surefire-reports: [report files not found in build]]
2022-11-11T13:20:03.7200288Z ##[warning]The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-11-11T13:20:03.7249054Z ##[error]Build status: FAILED

Can someone let me know how can I not fail the job if no report files are found?


Solution

  • I created an empty surefire report xml, dummy.xml under <java_src_root>/target/surefire-reports

    <?xml version="1.0" encoding="UTF-8"?>
    <testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" name="" time="" tests="0" errors="0" skipped="0" failures="0"/>