Space Automation: stop job when some command inside shellScript return exit code different to 0

Hi, I need to stop the job execution when Rubocop rules fail. I configured rubocop to throw an error when it finds any offenses and I checked that the exit code is 1 when there are any offense, but during the job execution, it ignores the process exit code and keep going to next command though failOn block has nonZeroExitCode enable true.


job("Development Deploy") {
startOn {
gitPush {
branchFilter {

nonZeroExitCode { enabled = true}

container(displayName = "Deploy", image = "ruby:2.7.3") {
env.set("RAILS_ENV", "development")
env["PUBLIC"] = Secrets("public_key")
env["PRIVATE"] = Secrets("private_key")

shellScript {
interpreter = "/bin/sh"
content = """
echo Installing dependencies
gem install bundler
gem install rails
bundle install
echo Excuting Rubocop
bundle exec rubocop



So I need to find a way stop the job execution when at least one command inside shell script fails I'll appreciate any help you can give me  

Comment actions Permalink

Hi Oscar, may I ask if you considered using `set -e` command which allows exiting shell immediately if any of executed commands exits with a non-zero status? Thanks!

Comment actions Permalink

Hi Pavel, it worked like a charm. Thank you so much! 


Please sign in to leave a comment.