Is there any convention or recommended way how to deal with cases when output need to be an array?
For example in official gradle-runner step there is an BITRISE_APK_PATH_LIST output which seems to be just file paths separated by pipe char|.
So when one of the paths contain | character (eg. app flavor name contains it) it becomes non-trivial to distinguish pipes in filenames from separators.
Isnāt it better to use for example a YAML/JSON array there?
Definitely would be, but you canāt do that with environment variables unfortunately. Env Vars are simple strings, no other data type is supported as an environment variable as far as I know.
Of course you can serialize data into string, e.g. serialize these infos as JSON and store that in an env var, then read and deserialize it in another step. If you have your own steps this is definitely possible, but that makes handling of these variables quite a bit more complex, e.g. handling JSON in Bash is not trivial at all unfortunately.
Why we chose the pipe char is because pipe should not be in the path. Pipes in shells are used for connecting commands, and AFAIK itās considered as a really bad practice to include it in a fileās name (due to the special meaning the char has in most shells).
I think the best solution might be to add a second output which would include the data in a JSON serialized form. That way simple steps which are only interested in the path list can be written in Bash, while the JSON output could include more info (e.g. mapping of paths) but would require a bit more complex logic to parse that output (json decoding).
Ahh, so itās the name of your flavor which includes the pipe char, not a ādefaultā android thing.
Weāll try to think about a better solution (I like the idea of a ārichā output encoded into JSON more and more). In the meantime Iād suggest you to use a different separator for your file name, if possible.
[quote=āviktorbenei, post:8, topic:2200ā]
In the meantime Iād suggest you to use a different separator for your file name, if possible.
[/quote]
This is not a real project but only playground to test our bitrise steps.
I wanted to consume BITRISE_APK_PATH_LIST in another step and realized that pipes may cause problems so I created this topic.
Sure, edge cases have to be covered and thatās part of why we have this forum & this sub category
The thing here is that thereās pretty much no char which is not allowed in a filename on a modern Unix system (AFAIK the only one is /), so we had to choose one which is unlikely to be in a path or any other value. Of course itās impossible to select one which works for every case, pipe seems to be a āsensible defaultā as a separator (but itās not hardcoded, just a suggestion to use |, every step is free to choose any separator if required).