Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to continue "on error" using Fastlane

I am trying to automate deployments into TestFlight using Fastlane. I want it to continue "on error" even if one of the lanes errors out.

For example, if I run "doall" below and "item1" errors out, I want it to still run "item2" and "item3".

Is this possible, if so how? Thanks!

lane :item1 do
 # Do some stuff
end

lane :item2 do
 # Do some stuff
end

lane :item3 do
 # Do some stuff
end

lane :doall do
 item1 # This causes an error
 item2
 item3
end

error do |lane, exception|
 # Send error notification
end
like image 435
tcarter2005 Avatar asked Jun 17 '16 21:06

tcarter2005


2 Answers

You can use Ruby error handling to do that

lane :item1 do
 # Do some stuff
end

lane :item2 do
 # Do some stuff
end

lane :item3 do
 # Do some stuff
end

lane :doall do
 begin
   item1 # This causes an error
 rescue => ex
   UI.error(ex)
 end
 begin
   item2
 rescue => ex
   UI.error(ex)
 end
 begin
   item3
 rescue => ex
   UI.error(ex)
 end
end

error do |lane, exception|
 # Send error notification
end

It's not super beautiful, but that's the best way to do it, if you want to catch errors for each of the lanes.

like image 106
KrauseFx Avatar answered Nov 19 '22 19:11

KrauseFx


Ruby

begin
  do_something_that_may_cause_error
rescue => ex
  # handle error
ensure
  # do something that always run like clean up
end

Swift

defer { 
  // do something that always run like clean up
}
do {
  try doSomethingThatMayCauseError()
} catch (error) {
  // handle error
}
like image 21
Ted Avatar answered Nov 19 '22 21:11

Ted