-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Hello, I'm having a hard time trying to rescue a failed command execution in a meaningful way.
Excerpt from my code:
section "helm chart" do
step "Check Helm Chart exists" do
ruby_command do
begin
command "gsutil ls \"gs://a-helm-repository-bucket/#{app_name}-#{chart_version}.tgz\""
rescue SSHKit::Command::Failed => e
puts "Failed", e.inspect
rescue SSHKit::Runner::ExecuteError => e
puts "ExecuteError", e.inspect
rescue => e
puts "generic exception", e.inspect
end
end
confirm "Does the Helm Chart exists?"
end
endThe goal of this snippet is to check if a GCP Cloud Storage Bucket Object for a Helm Chart is present, given an application name and a version (taken from user input).
Unfortunately though, I'm not able to rescue the exception in any meaningful way. I tried using raise_on_non_zero_exit but the effect is not what I'd want to achieve.
I'd like to be able to nicely handle known exceptions from this command, by inspecting the exception message and taking appropriate action. As I'm within a ruby_command I was expecting this to work (it should in any case probably?).
Is this even possible? If yes, how could I achieve the expected result? If not, any viable workaround?
Thanks!