Reputation: 821
On a giltab ci job I am running a node.js script where I evaluate some conditions, and where I might want to force the job to fail.
The script is written in es6 and is ran with yarn and babel-node yarn babel-node ./script-in-es6.js
.
When the condition fails I would like the job to fail. I have tried the following:
throw new Error('job failed')
process.exit(1)
require('shelljs').exit(1)
But none of these commands are enough to fail the job, it always succeeds. Is there a proper way to successfully fail a job in gitlab from node.js?
Upvotes: 5
Views: 1791
Reputation: 6321
If your script really does return exit code 1, try this:
script:
- <run your script> || export RES="$?"
- exit $RES
Upvotes: 0