Multiple paths in a single variable for Cache: Push

build-cache

#1

Description of the feature request

In Input Variables section under Bitrise.io Cache:Push, you can set multiple paths separated with newlines; But I need to set multiple paths with a variable defined with a script

Use case / for what or how I would use it

Homebrew can use a Brewfile to declare bundles required for a project, but it doesn’t install those bundles in a specific directory, but in /usr/local/Cellar and /usr/local/opt with all other bundles, which means you can’t just cache the whole brew install path, because it’s too big and contains too many unrelated libraries.

So I need to define a variable that contains those paths with shell script, but I’ve tried several ways including define an array variable and a string variable simply contains \n characters between paths, but none of them worked.

Here’s what I’ve tried as a sample:

bundle_paths=""
install_paths=""
cellar_path=$(brew --cellar)
install_path="/usr/local/opt"
bundles=$(brew bundle list)

for bundle in ${bundles[@]}; do
  bundle_paths+=$cellar_path/$bundle$'\n'
  install_paths+=$install_path/$bundle$'\n'
done

envman add --key BREW_BUNDLE_PATHS --value $bundle_paths
envman add --key BREW_INSTALL_PATHS --value $install_paths

And in Cache:Push Input Variables I’ve added $BREW_BUNDLE_PATHS and $BREW_INSTALL_PATHS, but it can only recognize the first path, so if I can define the paths with a single variable it’d be very helpful.

Thanks!