Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
catch exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaiBapchya committed Oct 1, 2019
1 parent f6a4e2d commit 67e45a5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ci/Jenkinsfile_utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ def collect_test_results_unix(original_file_name, new_file_name) {
sh 'cp ' + original_file_name + ' ' + new_file_name
archiveArtifacts artifacts: new_file_name
if (env.BRANCH_NAME == "master") {
s3Upload(file:new_file_name, bucket:env.MXNET_CI_UNITTEST_ARTIFACT_BUCKET, path:utils.get_git_commit_hash().trim()+"-"+env.BUILD_TAG+"/"+new_file_name)
try {
s3Upload(file:new_file_name, bucket:env.MXNET_CI_UNITTEST_ARTIFACT_BUCKET, path:utils.get_git_commit_hash().trim()+"-"+env.BUILD_TAG+"/"+new_file_name)
} catch (Exception e) {
sh "S3 Upload failed ${e}"

This comment has been minimized.

Copy link
@marcoabreu

marcoabreu Oct 1, 2019

Contributor

Why don't you rethrow it?

This comment has been minimized.

Copy link
@ChaiBapchya

ChaiBapchya Oct 1, 2019

Author Contributor

I used the catch Just to log the error. We dont want the job to fail even if S3 upload doesn't happen for some reason.
About rethrowing well I can do that - any reason why we should rethrow specifically here?

This comment has been minimized.

Copy link
@marcoabreu

marcoabreu Oct 1, 2019

Contributor

Well as far as I know AWS, I wouldn't expect this to fail except in case of a user error (e.g. missing file, typo, etc). So I'd say that we don't want to swallow it.

As it looks right now, that error would just be swallowed and go unnoticed.

Well you have to rethrow here because you're also catching it here. Otherwise, it would just bubble up to the exception handler

}
}
}
}
Expand All @@ -147,7 +151,11 @@ def collect_test_results_windows(original_file_name, new_file_name) {
bat 'xcopy ' + original_file_name + ' ' + new_file_name + '*'
archiveArtifacts artifacts: new_file_name
if (env.BRANCH_NAME == "master") {
s3Upload(file:new_file_name, bucket:env.MXNET_CI_UNITTEST_ARTIFACT_BUCKET, path:utils.get_git_commit_hash().trim()+"-"+env.BUILD_TAG+"/"+new_file_name)
try {
s3Upload(file:new_file_name, bucket:env.MXNET_CI_UNITTEST_ARTIFACT_BUCKET, path:utils.get_git_commit_hash().trim()+"-"+env.BUILD_TAG+"/"+new_file_name)
} catch (Exception e) {
sh "S3 Upload failed ${e}"
}
}
}
}
Expand Down

0 comments on commit 67e45a5

Please sign in to comment.