Reputation: 571
I am running Jenkins as a CI/CD pipeline for a project. To make things easier for my self, I have created a bash script to run the tests and send coverage report, here is my bash script:
#!/bin/bash
echo $GIT_COMMIT # only needed for debugging
GIT_COMMIT=$(git log | grep -m1 -oE '[^ ]+$')
echo $GIT_COMMIT # only needed for debugging
./cc-test-reporter before-build
yarn test --coverage
./cc-test-reporter after-build -t simplecov --exit-code $? || echo “Skipping Code Climate coverage upload”
And this is how I am running it in Jenkins:
sh "jenkins/scripts/load_env_variables.sh test"
Jenkins runs the script, however when the script fails, Jenkins does not exit, rather it continues:
Any help with this please?
Upvotes: 0
Views: 539
Reputation: 38
Use "set -e" in script.
-e Exit immediately if a command exits with a non-zero status.
Upvotes: 2