Reputation: 421
I have a pipeline script that executes a build as one of its steps. Let's say it looks like this:
pipeline{
stages {
stage('Build'){
steps{
node('master'){
build job: 'my_build'
}
}
}
(other stages.........)
}
}
Occasionally, that step ("Build") fails. I have a shell script in the "Build" job (an "Execute shell" step) that exits with a certain return code that I then exit the step with, like so:
#!/bin/bash
./my_build_script.sh
exit $?
The problem is, I'm not sure how to capture that exit code for use later in the pipeline.
What I'd like to achieve is only retrying the build on a particular exit code from that "Execute shell" step.
Upvotes: 1
Views: 765
Reputation: 166
By storing in variable?
./my_build_script.sh
get_status=$?
Upvotes: 1