Always run record tests

The launchable record tests command must always run even if the test run succeeds or fails. 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 has post { always { ... } } option:

pipeline {
sh 'bundle exec rails test -v $(cat launchable-subset.txt)'
post {
always {
sh 'launchable record tests <BUILD NAME> [OPTIONS]'


CircleCI has when: always option:

- jobs:
- test:
- run:
name: Run tests
command: bundle exec rails test -v $(cat launchable-subset.txt)
- run:
name: Record test results
command: launchable record tests <BUILD NAME> [OPTIONS]
when: always

Github Actions

GithubAction has if: ${{ always() }} option:

- name: Run tests
run: bundle exec rails test -v $(cat launchable-subset.txt)
- name: Record test result
run: launchable record tests <BUILD NAME> [OPTIONS]
if: always()


If you run tests on your local or other CI, you can use trap:

function record() {
launchable record tests <BUILD NAME> [OPTIONS]
# set a trap to send test results to Launchable for this build either tests succeed/fail
trap record EXIT SIGHUP
bundle exec rails test -v $(cat launchable-subset.txt)