Iām trying to use a fastlane step to send my APK to crashlytics, similarly as what I do from my own computer.
However I canāt get access the environment variable BITRISE_APK_PATH in my script.
I tried the following in my (local) fastfile and some variations but no success, I always the error message : āYou have to either pass an ipa or an apk file to the Crashlytics actionā
fastlane uses Ruby as itās config language, and in Ruby you reference environment variables with ENV['ENV_KEY']. In the case above: ENV['BITRISE_APK_PATH']. Note: thereās no $ in the ID!
The $ENV_KEY / ${ENV_KEY} environment variable value reference style is common in script languages like Bash, which is the most common āglueā script language on Mac/Linux, thatās why we opted to use that style in inputs. But in general, these are just environment variables, so you just have to check how in the language of your choice you can reference env vars.
If you have any questions just let us know!
Happy Building!
Thanks for your answer and your precisions. Indeed, now I succesfully get the variable, since Iām able to display it. However, I have a subsequent issue, here is my log. Is this linked or should I create a separate topic ?
$ fastlane "fabric_upload"
[08:25:22]: -------------------------------------------------
[08:25:22]: --- Step: Verifying required fastlane version ---
[08:25:22]: -------------------------------------------------
[08:25:22]: Your fastlane version 2.23.0 matches the minimum requirement of 2.3.1 ā
[08:25:22]: ------------------------------
[08:25:22]: --- Step: default_platform ---
[08:25:22]: ------------------------------
[08:25:22]: Driving the lane 'fabric_upload' š
[08:25:22]: ApkPath is /bitrise/deploy/app-dev-release.apk //This is a puts
[08:25:22]: -------------------------
[08:25:22]: --- Step: crashlytics ---
[08:25:22]: -------------------------
[08:25:22]: Downloading Crashlytics Support Library - this might take a minute...
[08:25:24]: $ unzip '/root/Library/CrashlyticsAndroid/crashlytics-devtools.zip' -d '/root/Library/CrashlyticsAndroid'
[08:25:24]: āø Archive: /root/Library/CrashlyticsAndroid/crashlytics-devtools.zip
[08:25:24]: āø inflating: /root/Library/CrashlyticsAndroid/crashlytics_build.xml
[08:25:24]: āø inflating: /root/Library/CrashlyticsAndroid/crashlytics_build_base.xml
[08:25:24]: āø inflating: /root/Library/CrashlyticsAndroid/crashlytics-devtools.jar
[08:25:24]: Succesfully downloaded Crashlytics Support Library to '/root/Library/CrashlyticsAndroid/crashlytics-devtools.jar'
[08:25:24]: Uploading the build to Crashlytics Beta. Time for some āļø.
[08:25:25]: WARN - The upload distribution task failed because it received invalid input. Contact support@fabric.io for help.
Exception in thread "main" com.crashlytics.tools.android.exception.PluginException: Distribution upload failed.
at com.crashlytics.tools.android.DeveloperTools.processProperties(DeveloperTools.java:667)
at com.crashlytics.tools.android.DeveloperTools.processArgsInternal(DeveloperTools.java:348)
at com.crashlytics.tools.android.DeveloperTools.main(DeveloperTools.java:273)
Caused by: com.crashlytics.tools.android.exception.DistributionException: The upload distribution task failed because it received invalid input. Contact support@fabric.io for help.
at com.crashlytics.tools.android.DistributionTasks.uploadDistribution(DistributionTasks.java:87)
at com.crashlytics.tools.android.DeveloperTools.processProperties(DeveloperTools.java:665)
... 2 more
+------------------+---------------+
| Lane Context |
+------------------+---------------+
| DEFAULT_PLATFORM | android |
| PLATFORM_NAME | |
| LANE_NAME | fabric_upload |
+------------------+---------------+
[08:25:25]: Shell command exited with exit status 1 instead of 0.
Yes, Iām quite sure itās here, because the line ApkPath is /bitrise/deploy/app-dev-release.apk
is actually the output of "puts "ApkPath is #{ApkPath}"
And the Gradle Runner output shows :
Move apk files...
find "." "-path" "*.apk" "!" "-path" "*-unaligned.apk"
copy ./app/build/outputs/apk/app-prod-release.apk to /bitrise/deploy/app-prod-release.apk
copy ./app/build/outputs/apk/app-dev-release.apk to /bitrise/deploy/app-dev-release.apk
The apk path is now available in the Environment Variable: $BITRISE_APK_PATH (value: /bitrise/deploy/app-dev-release.apk)
It might also be that the mentioned āinputā is not the APK path (e.g. a missing API key or similar) - itās probably better to contact fastlane support, thereās nothing obvious/bitrise related popping out of the log⦠The local debug I linked might help, maybe you can figure out what causes this issue that way.
Just in case it can help anyone, what worked for me was to access them by using environment_variable(get: "env_var_name") action from fastlane.
I attach an image for better understanding.