Skip to content

Fastlane swift: exit code 0 even when lane fails #20649

@kalinjul

Description

@kalinjul

New Issue Checklist

Issue Description

This is to reopen #20419. Still happens on latest fastlane.

Hi,
we're using fastlane swift and noticed that our pipelines were always green, regardless of errors in fastlane runs.
So i looked into fastlane swift and indeed, it does not exit with an error code at any point.
Errors are recorded:

LaneFile.onErrorCalled.insert(currentLane)

And if errors occured, "after" actions are not called:
if !LaneFile.onErrorCalled.contains(lane) {

But it just exists successfully everytime. Is this expected? IMHO, it makes fastlane useless in pipelines as i don't want to deploy e.g. when tests fail :)

I have a PR open to fix this.

Command executed

fastlane lane archive

Complete output when running fastlane, including the stack trace and command used

Example of a failed run with exit code 0 in gitlab:

[1655721736.9429178]: error encountered while executing command:
serverError
[1655721736.942967]: Encountered a problem: FastlaneCore::Interface::FastlaneBuildFailure:
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane_core/lib/fastlane_core/ui/interface.rb:163:in `build_failure!'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in `method_missing'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/gym/lib/gym/error_handler.rb:73:in `handle_build_error'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/gym/lib/gym/runner.rb:114:in `block in build_app'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane_core/lib/fastlane_core/command_executor.rb:84:in `execute'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/gym/lib/gym/runner.rb:110:in `build_app'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/gym/lib/gym/runner.rb:18:in `run'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/gym/lib/gym/manager.rb:19:in `work'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/actions/build_app.rb:68:in `run'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/actions/build_ios_app.rb:22:in `run'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/runner.rb:263:in `block (2 levels) in execute_action'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/actions/actions_helper.rb:69:in `execute_action'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/runner.rb:229:in `chdir'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/runner.rb:229:in `execute_action'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server_action_command_executor.rb:73:in `run'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server_action_command_executor.rb:42:in `execute'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server.rb:181:in `execute_action_command'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server.rb:176:in `process_action_command'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server.rb:123:in `handle_action_command'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server.rb:86:in `parse_and_execute_command'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server.rb:62:in `block in receive_and_process_commands'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server.rb:49:in `loop'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server.rb:49:in `receive_and_process_commands'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server.rb:158:in `listen'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/server/socket_server.rb:38:in `start'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/commands_generator.rb:166:in `block (2 levels) in run'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in `run!'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/commands_generator.rb:353:in `run'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/commands_generator.rb:42:in `start'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/fastlane/lib/fastlane/cli_tools_distributor.rb:122:in `take_off'
/usr/local/Cellar/fastlane/2.204.3/libexec/gems/fastlane-2.204.3/bin/fastlane:23:in `<top (required)>'
/usr/local/Cellar/fastlane/2.204.3/libexec/bin/fastlane:25:in `load'
/usr/local/Cellar/fastlane/2.204.3/libexec/bin/fastlane:25:in `<main>'
[1655721736.942987]: Done running lane: build 🚀
section_end:1655721736:step_script
�[0Ksection_start:1655721736:archive_cache
�[0K�[0K�[36;1mSaving cache for successful job�[0;m�[0;m
�[32;1mCreating cache fastlane-binary-cache-280336-non_protected...�[0;m
Runtime platform                                  �[0;m  arch�[0;m=amd64 os�[0;m=darwin pid�[0;m=19111 revision�[0;m=98daeee0 version�[0;m=14.7.0
./FastlaneRunner/.build/x86_64-apple-macosx/debug/FastlaneRunner: found 1 matching files and directories�[0;m 
Archive is up to date!                            �[0;m 
�[32;1mCreated cache�[0;m
section_end:1655721737:archive_cache
�[0Ksection_start:1655721737:upload_artifacts_on_success
�[0K�[0K�[36;1mUploading artifacts for successful job�[0;m�[0;m
�[32;1mUploading artifacts...�[0;m
Runtime platform                                  �[0;m  arch�[0;m=amd64 os�[0;m=darwin pid�[0;m=19121 revision�[0;m=98daeee0 version�[0;m=14.7.0
section_end:1655721737:upload_artifacts_on_success
�[0Ksection_start:1655721737:cleanup_file_variables
�[0K�[0K�[36;1mCleaning up project directory and file based variables�[0;m�[0;m
section_end:1655721737:cleanup_file_variables
�[0K�[32;1mJob succeeded�[0;m

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions