Unable to pass a custom variable in balena deploy build args

I am attempting to execute a bit of shell script inside my balena deploy build argument, however I continue to receive the error “Could not parse build argument.” What would be the correct format to execute the command and pass the argument successfully?

The command I am currently using in balena deploy DigitalSignageDisplay --logs --source . --emulated --build --buildArg "'ARG=$(cat ~/file.txt)'"

Could it be that file.txt contains some shell-special characters like a single quote? In which case, it would need to be escaped somehow. Is that the question, how to escape it somehow? :slight_smile:

I know that it contains new lines, but I checked and there are no shell-special characters inside.
Maybe there is a better way to escape the command so that those don’t cause an issue?

I have found that the balena CLI was testing the ARG value against a regular expression that does not allow newline characters, and I have created a pull request that appears to solve the problem:

The PR is pending review – reviewers may know of reasons why line break characters should not be allowed. Otherwise, it should get merged and released very soon.

Awesome! Once again thanks for the quick response. This pull request should help align the CLI with the normal Docker build args argument.

The PR was merged and released in CLI version 10.17.2. It is now possible use line breaks in the argument value for the --buildArg option of the build and deploy commands.