Ensuring `record tests` always runs
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

Jenkins has post { always { ... } } option:
1
pipeline {
2
...
3
sh 'bundle exec rails test -v $(cat launchable-subset.txt)'
4
...
5
post {
6
always {
7
sh 'launchable record tests <BUILD NAME> [OPTIONS]'
8
}
9
}
10
}
Copied!

CircleCI

CircleCI has when: always option:
1
- jobs:
2
- test:
3
...
4
- run:
5
name: Run tests
6
command: bundle exec rails test -v $(cat launchable-subset.txt)
7
- run:
8
name: Record test results
9
command: launchable record tests <BUILD NAME> [OPTIONS]
10
when: always
Copied!

Github Actions

GithubAction has if: ${{ always() }} option:
1
jobs:
2
test:
3
steps:
4
...
5
- name: Run tests
6
run: bundle exec rails test -v $(cat launchable-subset.txt)
7
- name: Record test result
8
run: launchable record tests <BUILD NAME> [OPTIONS]
9
if: always()
Copied!

Bash

If you run tests on your local or other CI, you can use trap:
1
function record() {
2
launchable record tests <BUILD NAME> [OPTIONS]
3
}
4
# set a trap to send test results to Launchable for this build either tests succeed/fail
5
trap record EXIT SIGHUP
6
​
7
bundle exec rails test -v $(cat launchable-subset.txt)
Copied!
Last modified 1mo ago