Splitting BITRISE_APK_PATH_LIST issue

I’m trying to take advantage of the recent BITRISE_APK_PATH_LIST, and to export each APK path of my flavors in a single evironnement variable. I’m having an issue when trying to use it in other steps.

Here is what I get from Gradle step :

The apk paths list is now available in the Environment Variable: $BITRISE_APK_PATH_LIST (value: /bitrise/deploy/xxx-dev-release.apk|/bitrise/deploy/xxx-prod-release.apk)

I split then the list in a script with :

IFS=’|’ tokens=($BITRISE_APK_PATH_LIST)
echo ${tokens[0]}|envman add --key APK_PATH_FLAVOR_0;echo ${tokens[1]}|envman add --key APK_PATH_FLAVOR_1;

I now have two variables, APK_PATH_FLAVOR_0 & APK_PATH_FLAVOR_1. I use them in two “Deploy to bitrise” steps, but I have the following error :

Configs:

  • BuildURL: https://www.bitrise.io/build/48c88955ae414a7f
  • APIToken: sqxQTKOP0EJMtvancWhHlA
  • IsCompress: false
  • DeployPath: /bitrise/deploy/xxx-dev-release.apk
  • NotifyUserGroups: everyone
  • NotifyEmailList:
  • IsPublicPageEnabled: true
    Issue with input: DeployPath - path not exist at: /bitrise/deploy/xxx-dev-release.apk

The step is successfull if I hardcode the “/bitrise/deploy/xxx-dev-release.apk” instead of using the variable generated by envman.

Any idea ?

Thanks in advance,

Hi @raphaelmina,

Please start your script with set -ex for debug logs. Eg

#!/bin/bash
set -ex

echo 'hi' 

If that wouldn’t help to find the issue then please copy paste the scripts log from the build log.

Hi @viktorbenei,

Thanks for the tip. I figured out what was the issue, without understanding the cause.

Here is the output of my “tokenize” step, after adding set -ex :

+ IFS='|'
+ tokens=($BITRISE_APK_PATH_LIST)
+ echo /bitrise/deploy/xxx-dev-release.apk
+ envman add --key APK_PATH_FLAVOR_0
+ echo /bitrise/deploy/xxx-prod-release.apk
+ envman add --key APK_PATH_FLAVOR_1

I think somehow, a line feed is inserted after each of my APK path, because I observe a line feed in my deploy path :

I tried to change the way I used envman, to this form :
envman add --key APK_PATH_FLAVOR_0 --value ${tokens[0]}

And this time the deploy step can find my APK, and there’s no line feed in my deploy path. I don’t get the cause, but apparently that’s fine now. If you have any explanation, I’m curious to hear it !

Thanks for your help,

1 Like

That indeed can happen if you use echo.

echo without the -n flag does add a newline to the end. To not to add a newline / line feed char to the end you should use echo -n or printf, or as you discovered just use the envman --key X --value VALUE format of envman, instead of the pipe input format.

2 Likes

Thanks a lot @viktorbenei ! I got the point !

1 Like