Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get raw exit code from Fastlane #21963

Open
4 tasks done
squarefrog opened this issue Apr 10, 2024 · 3 comments
Open
4 tasks done

How to get raw exit code from Fastlane #21963

squarefrog opened this issue Apr 10, 2024 · 3 comments

Comments

@squarefrog
Copy link
Contributor

squarefrog commented Apr 10, 2024

New Issue Checklist

Issue Description

When a lane or action has an exit code, fastlane always returns an exit code of 1. In the attached example, the unit tests fail with an exit code of 65, but theres seemingly no way to get this.

This would be useful for the CI to retry unit test crashes, but not unit test failures. Here is a sample project you can use to test this behaviour.

Similarly, if I use bundle exec fastlane scan standalone, it still only returns an exit code of 1.

Command executed
$ bundle exec fastlane tests
$ echo $?
Complete output when running fastlane, including the stack trace and command used
 ❯ bundle exec fastlane tests
[✔] 🚀
[08:24:01]: ------------------------------
[08:24:01]: --- Step: default_platform ---
[08:24:01]: ------------------------------
[08:24:01]: Driving the lane 'ios tests' 🚀
[08:24:01]: ------------------
[08:24:01]: --- Step: scan ---
[08:24:01]: ------------------
[08:24:01]: Resolving Swift Package Manager dependencies...
[08:24:01]: $ xcodebuild -resolvePackageDependencies -scheme ExitCodes -project ./ExitCodes.xcodeproj
[08:24:01]: ▸ Command line invocation:
[08:24:01]: ▸     /Applications/Xcode-15.3.0-Release.Candidate.2.app/Contents/Developer/usr/bin/xcodebuild -resolvePackageDependencies -scheme ExitCodes -project ./ExitCodes.xcodeproj
[08:24:01]: ▸ User defaults from command line:
[08:24:01]: ▸     IDEPackageSupportUseBuiltinSCM = YES
[08:24:01]: ▸ resolved source packages:
[08:24:01]: $ xcodebuild -showBuildSettings -scheme ExitCodes -project ./ExitCodes.xcodeproj 2>&1
[08:24:03]: Found simulator "iPhone SE (3rd generation) (17.4)"

+----------------------------------------------------------------------------------------------------------------------------------------+
| Summary for scan 2.220.0 |
+------------------------------------------------+---------------------------------------------------------------------------------------+
| project | ./ExitCodes.xcodeproj |
| scheme | ExitCodes |
| skip_detect_devices | false |
| ensure_devices_found | false |
| force_quit_simulator | false |
| reset_simulator | false |
| disable_slide_to_type | true |
| reinstall_app | false |
| clean | false |
| open_report | false |
| output_directory | ./fastlane/test_output |
| output_types | html,junit |
| buildlog_path | ~/Library/Logs/scan |
| include_simulator_logs | false |
| xcodebuild_formatter | xcbeautify |
| output_remove_retry_attempts | false |
| derived_data_path | /Users/paulwilliamson/Library/Developer/Xcode/DerivedData/ExitCodes-gjkhbfdttfztyigi |
| | kgndojlrqkwb |
| should_zip_build_products | false |
| output_xctestrun | false |
| result_bundle | false |
| use_clang_report_name | false |
| disable_concurrent_testing | false |
| skip_build | false |
| slack_use_webhook_configured_username_and_icon | false |
| slack_username | fastlane |
| slack_icon_url | https://fastlane.tools/assets/img/fastlane_icon.png |
| skip_slack | false |
| slack_only_on_failure | false |
| run_rosetta_simulator | false |
| xcodebuild_command | env NSUnbufferedIO=YES xcodebuild |
| skip_package_dependencies_resolution | false |
| disable_package_automatic_updates | false |
| use_system_scm | false |
| number_of_retries | 0 |
| fail_build | true |
| xcode_path | /Applications/Xcode-15.3.0-Release.Candidate.2.app |
+------------------------------------------------+---------------------------------------------------------------------------------------+

[08:24:03]: Disabling 'Slide to Type' iPhone SE (3rd generation)
[08:24:03]: $ /usr/libexec/PlistBuddy -c "Add :KeyboardContinuousPathEnabled bool false" /Users/paulwilliamson/Library/Developer/CoreSimulator/Devices/989E3E15-B699-43D1-A2CA-074D9929AF4C/data/Library/Preferences/com.apple.keyboard.ContinuousPath.plist >/dev/null 2>&1
[08:24:03]: $ set -o pipefail && env NSUnbufferedIO=YES xcodebuild -scheme ExitCodes -project ./ExitCodes.xcodeproj -derivedDataPath /Users/paulwilliamson/Library/Developer/Xcode/DerivedData/ExitCodes-gjkhbfdttfztyigikgndojlrqkwb -destination 'platform=iOS Simulator,id=989E3E15-B699-43D1-A2CA-074D9929AF4C' build test | tee '/Users/paulwilliamson/Library/Logs/scan/ExitCodes-ExitCodes.log' | xcbeautify
[08:24:03]: ▸ Loading...
[08:24:04]: ▸ --- xcodebuild: WARNING: Using the first of multiple matching destinations:
[08:24:04]: ▸ { platform:iOS Simulator, id:989E3E15-B699-43D1-A2CA-074D9929AF4C, OS:17.4, name:iPhone SE (3rd generation) }
[08:24:04]: ▸ { platform:iOS Simulator, id:989E3E15-B699-43D1-A2CA-074D9929AF4C, OS:17.4, name:iPhone SE (3rd generation) }
[08:24:12]: ▸ [ExitCodes] Processing empty-ExitCodes.plist
[08:24:12]: ▸ Signing ExitCodes.app (in target 'ExitCodes' from project 'ExitCodes')
[08:24:12]: ▸ Build Succeeded
[08:24:12]: ▸ --- xcodebuild: WARNING: Using the first of multiple matching destinations:
[08:24:12]: ▸ { platform:iOS Simulator, id:989E3E15-B699-43D1-A2CA-074D9929AF4C, OS:17.4, name:iPhone SE (3rd generation) }
[08:24:12]: ▸ { platform:iOS Simulator, id:989E3E15-B699-43D1-A2CA-074D9929AF4C, OS:17.4, name:iPhone SE (3rd generation) }
[08:24:13]: ▸ [ExitCodes] Processing empty-ExitCodes.plist
[08:24:13]: ▸ [ExitCodesTests] Processing empty-ExitCodesTests.plist
[08:24:13]: ▸ Signing ExitCodesTests.xctest (in target 'ExitCodesTests' from project 'ExitCodes')
[08:24:13]: ▸ Signing ExitCodes.app (in target 'ExitCodes' from project 'ExitCodes')
[08:24:35]: ▸ Test Suite ExitCodesTests started on 'Clone 1 of iPhone SE (3rd generation) - ExitCodes (39378)'
[08:24:35]: ▸ ✖ test_failingTest on 'Clone 1 of iPhone SE (3rd generation) - ExitCodes (39378)' (0.094 seconds)
[08:24:52]: ▸ 2024-04-10 08:24:52.731 xcodebuild[39129:3815875] [MT] IDETestOperationsObserverDebug: 39.339 elapsed -- Testing started completed.
[08:24:52]: ▸ 2024-04-10 08:24:52.731 xcodebuild[39129:3815875] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
[08:24:52]: ▸ 2024-04-10 08:24:52.731 xcodebuild[39129:3815875] [MT] IDETestOperationsObserverDebug: 39.339 sec, +39.339 sec -- end
[08:24:54]: ▸ Failing tests:
[08:24:54]: ▸ ExitCodesTests.test_failingTest()
[08:24:54]: ▸ ** TEST FAILED **
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:989E3E15-B699-43D1-A2CA-074D9929AF4C, OS:17.4, name:iPhone SE (3rd generation) }
{ platform:iOS Simulator, id:989E3E15-B699-43D1-A2CA-074D9929AF4C, OS:17.4, name:iPhone SE (3rd generation) }
[ExitCodes] Processing empty-ExitCodes.plist
Signing ExitCodes.app (in target 'ExitCodes' from project 'ExitCodes')
Build Succeeded
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:989E3E15-B699-43D1-A2CA-074D9929AF4C, OS:17.4, name:iPhone SE (3rd generation) }
{ platform:iOS Simulator, id:989E3E15-B699-43D1-A2CA-074D9929AF4C, OS:17.4, name:iPhone SE (3rd generation) }
[ExitCodes] Processing empty-ExitCodes.plist
[ExitCodesTests] Processing empty-ExitCodesTests.plist
Signing ExitCodesTests.xctest (in target 'ExitCodesTests' from project 'ExitCodes')
Signing ExitCodes.app (in target 'ExitCodes' from project 'ExitCodes')
Test Suite ExitCodesTests started on 'Clone 1 of iPhone SE (3rd generation) - ExitCodes (39378)'
✖ test_failingTest on 'Clone 1 of iPhone SE (3rd generation) - ExitCodes (39378)' (0.094 seconds)
2024-04-10 08:24:52.731 xcodebuild[39129:3815875] [MT] IDETestOperationsObserverDebug: 39.339 elapsed -- Testing started completed.
2024-04-10 08:24:52.731 xcodebuild[39129:3815875] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2024-04-10 08:24:52.731 xcodebuild[39129:3815875] [MT] IDETestOperationsObserverDebug: 39.339 sec, +39.339 sec -- end
Failing tests:
ExitCodesTests.test_failingTest()

** TEST FAILED **
[08:24:57]: Exit status: 65
[08:24:57]: Skipping HTML... only available with xcodebuild_formatter: 'xcpretty' right now
[08:24:57]: Your 'xcodebuild_formatter' doesn't support these 'output_types'. Change your 'output_types' to prevent these warnings from showing...
+------------------------+
| Test Results |
+--------------------+---+
| Number of tests | 1 |
| Number of failures | 1 |
+--------------------+---+

+----------------------------------------------------------------------------------------------------------------------+
| Lane Context |
+------------------------------+---------------------------------------------------------------------------------------+
| DEFAULT_PLATFORM | ios |
| PLATFORM_NAME | ios |
| LANE_NAME | ios tests |
| SCAN_GENERATED_XCRESULT_PATH | /Users/paulwilliamson/Library/Developer/Xcode/DerivedData/ExitCodes-gjkhbfdttfztyigi |
| | kgndojlrqkwb/Logs/Test/Run-ExitCodes-2024.04.10_08-24-04-+0100.xcresult |
| SCAN_DERIVED_DATA_PATH | /Users/paulwilliamson/Library/Developer/Xcode/DerivedData/ExitCodes-gjkhbfdttfztyigi |
| | kgndojlrqkwb |
| SCAN_GENERATED_PLIST_FILES | [] |
| SCAN_GENERATED_PLIST_FILE | |
+------------------------------+---------------------------------------------------------------------------------------+
[08:24:57]: Tests have failed

+---------------------------------------+
| fastlane summary |
+------+------------------+-------------+
| Step | Action | Time (in s) |
+------+------------------+-------------+
| 1 | default_platform | 0 |
| 💥 | scan | 56 |
+------+------------------+-------------+

[08:24:57]: fastlane finished with errors

[!] Tests have failed

Environment

 
✅ fastlane environment ✅

Stack

Key Value
OS 14.4.1
Ruby 2.7.2
Bundler? false
Git git version 2.43.0
Installation Source ~/.rbenv/versions/2.7.2/bin/fastlane
Host macOS 14.4.1 (23E224)
Ruby Lib Dir ~/.rbenv/versions/2.7.2/lib
OpenSSL Version OpenSSL 1.1.1l 24 Aug 2021
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode-15.3.0-Release.Candidate.2.app/Contents/Developer/
Xcode Version 15.3
Swift Version 5.10

System Locale

Variable Value
LANG en_GB.UTF-8
LC_ALL en_GB.UTF-8
LANGUAGE

fastlane files:

`./fastlane/Fastfile`
default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"
  lane :tests do
    scan
  end
end

No Appfile found

fastlane gems

Gem Version Update-Status
fastlane 2.220.0 ✅ Up-To-Date

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
did_you_mean 1.4.0
babosa 1.0.4
colored 1.2
highline 2.0.3
commander 4.6.0
emoji_regex 3.2.3
faraday_middleware 1.2.0
faraday-cookie_jar 0.0.7
gh_inspector 1.1.3
google-cloud-env 1.6.0
http-cookie 1.0.5
naturally 2.2.1
rubyzip 2.3.2
security 0.1.5
terminal-notifier 2.0.0
terminal-table 3.0.2
tty-cursor 0.7.1
tty-spinner 0.9.3
word_wrap 1.0.0
rouge 2.0.7
xcpretty 0.3.0
xcpretty-travis-formatter 1.0.1
uri 0.10.0
public_suffix 5.0.5
addressable 2.8.6
artifactory 3.0.17
aws-eventstream 1.3.0
aws-sigv4 1.8.0
aws-partitions 1.910.0
jmespath 1.6.2
aws-sdk-core 3.191.6
aws-sdk-kms 1.78.0
aws-sdk-s3 1.146.1
bundler 2.2.31
base64 0.2.0
nkf 0.2.0
rexml 3.2.6
CFPropertyList 3.0.7
dotenv 2.8.1
excon 0.110.0
ruby2_keywords 0.0.5
faraday-retry 1.0.3
faraday-rack 1.0.0
faraday-patron 1.0.0
faraday-net_http_persistent 1.2.0
faraday-net_http 1.0.1
multipart-post 2.4.0
faraday-multipart 1.0.4
faraday-httpclient 1.0.1
faraday-excon 1.1.0
faraday-em_synchrony 1.0.0
faraday-em_http 1.0.0
faraday 1.10.3
fastimage 2.3.1
httpclient 2.8.3
multi_json 1.15.0
jwt 2.8.1
signet 0.19.0
os 1.1.4
googleauth 1.8.1
mini_mime 1.1.5
retriable 3.1.2
trailblazer-option 0.1.2
declarative 0.0.20
uber 0.1.0
representable 3.2.0
google-apis-core 0.11.3
google-apis-androidpublisher_v3 0.54.0
google-apis-playcustomapp_v1 0.13.0
rake 13.2.1
digest-crc 0.6.5
google-apis-storage_v1 0.31.0
google-apis-iamcredentials_v1 0.17.0
google-cloud-errors 1.4.0
google-cloud-core 1.7.0
google-cloud-storage 1.47.0
domain_name 0.6.20240107
json 2.7.2
mini_magick 4.12.0
optparse 0.4.0
plist 3.7.1
simctl 1.6.10
unicode-display_width 2.5.0
tty-screen 0.8.2
nanaimo 0.3.0
colored2 3.1.2
claide 1.1.0
atomos 0.1.3
xcodeproj 1.24.0
forwardable 1.3.1
logger 1.4.2
cgi 0.1.0
date 3.0.0
timeout 0.1.0
stringio 0.1.0
ipaddr 1.2.2
openssl 2.1.2
zlib 1.1.0
mutex_m 0.1.0
strscan 1.0.3
io-console 0.5.6
delegate 0.1.0
fileutils 1.4.1
singleton 0.1.0
open3 0.1.0
nokogiri 1.13.9
racc 1.6.0
yaml 0.1.0
psych 3.1.0
ostruct 0.2.0

generated on: 2024-04-10

@lucgrabowski
Copy link
Contributor

Hi, I am not sure it that's currently possible to get the exit status of scan command, but you could take a look at scan/lib/scan/runner, fastlane_core/lib/fastlane_core/command_executor. If it's not available, maybe adding such a feature wouldn't be difficult 🤔
https://github.com/fastlane/fastlane/blob/master/scan/lib/scan/runner.rb
https://github.com/fastlane/fastlane/blob/master/fastlane_core/lib/fastlane_core/command_executor.rb

@Potter553
Copy link

Potter553 commented Apr 30, 2024

To get the raw exit code from Fastlane, you can use the following command in your terminal or shell script:

fastlane [lane_name] --raw

Replace [lane_name] with the name of the lane you want to run. The --raw option tells Fastlane to print only the raw exit code without any additional output or formatting.
Palm Beach County Property Appraiser
For example, if you want to run a lane named deploy and get the raw exit code, you would use:

fastlane deploy --raw

This command will execute the deploy lane in your Fastfile and print the raw exit code to the terminal. You can then use this exit code in your scripts or workflows as needed.

@squarefrog
Copy link
Contributor Author

Does this mean we lose pretty printing for the rest of the output though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants