Skip to content

Commit 5e43ae8

Browse files
committed
catch exceptions thrown by sh step running pr-builder.sh
If the pr-builder fails, the sh step running it will throw an exception. This exception prevents later steps from running. If this exception is raised, we catch it so the job can properly finish. However, catching the exception will set the overall job status to sucess, but we can manually set it back to a failure. Signed-off-by: Joe Downs <joe@dwns.dev>
1 parent 67620f4 commit 5e43ae8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.ci/community-jenkins/Jenkinsfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,16 @@ def prepare_build(build_name, label, build_arg) {
7979
stage("${build_name}") {
8080
node(label) {
8181
checkout(changelog: false, poll: false, scm: scm)
82-
sh "/bin/bash -x .ci/community-jenkins/pr-builder.sh ${build_arg} ompi"
82+
// If pr-builder.sh fails, the sh step will throw an exception,
83+
// which we catch so that the job doesn't abort and continues on
84+
// to other steps - such as cleanup. Because we catch the
85+
// exception, we need to tell Jenkins the overall job has
86+
// failed.
87+
try {
88+
sh "/bin/bash -x .ci/community-jenkins/pr-builder.sh ${build_arg} ompi"
89+
} catch (Exception e) {
90+
currentBuild.result = "FAILURE"
91+
}
8392
cleanWs(notFailBuild: true)
8493
}
8594
}

0 commit comments

Comments
 (0)