|
This page relates to Record test results with CloudBees Smart Tests. |
The smart-tests record tests command must be executed after you run tests.
However, some tools exit the build process as soon as the test process finishes, preventing this from happening.
The way to fix this depends on your CI tool:
Jenkins
For declarative Pipeline jobs, use the post { always { … } } option:
pipeline { ... sh 'bundle exec rails test -v $(cat smart-tests-subset.txt)' ... post { always { sh 'smart-tests record tests <BUILD NAME> [OPTIONS]' } } }
For scripted pipeline jobs, the catchError step should be used as described here: https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#catcherror-catch-error-and-set-build-result-to-failure.
|
This is unnecessary for Maven builds that use the |
CircleCI
CircleCI has the when: always option, described here: https://circleci.com/docs/reference/configuration-reference/#the-when-attribute.
- jobs: - test: ... - run: name: Run tests command: bundle exec rails test -v $(cat smart-tests-subset.txt) - run: name: Record test results command: smart-tests record tests <BUILD NAME> [OPTIONS] when: always
GitHub Actions
GitHub Action has the if: ${{ always() }} option, described here: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#always.
jobs: test: steps: ... - name: Run tests run: bundle exec rails test -v $(cat smart-tests-subset.txt) - name: Record test result run: smart-tests record tests <BUILD NAME> [OPTIONS] if: always()