How to pass dynamic variables in firebase database set command?

I want to update the build version number at the firebase, so I am running a firebase command through a bash file that looks like this-

sudo firebase database:set /build_version --data '"1.1.13.12.34"' --project <PROJECT_ID>

This is working fine.

But, I want to pass the version number dynamically, so I would like to write this command something like that-

VERSION=<ANY_NUMBER>
sudo firebase database:set /build_version --data $VERSION --project <PROJECT_ID>

But passing dynamic variable giving me an error-

Error: Unexpected error while setting data: FirebaseError: HTTP Error: 400, Invalid data; couldn't parse JSON object, array, or value.

I have read that firebase doesn't allow some special character and we cannot wrap firebase data in double-quotes

At firebase, "build_version" is not a JSON Object. It's a single variable. My real-time database structure is looking like this-

enter image description here

Can anyone suggest how can I pass the dynamic data to the firebase database command?


Solution 1:

Sharing just a trick

If firebase doesn't allow using special characters then you can just put any string (let's say BUILD_VERSION) instead of your shell script variable $VERSION and then using shell script syntax just search and replace that string with your build version before running firebase command. In the end, you can again replace the build version with the string BUILD_VERSION.