Say my MySQL password looks like this
T#`DEAE&H29r23328h23c@#X21
which contains a backtick. Of course, it might contain a " or ' or $ or other expandable sequence.
When variable substitution occurs in a deployment plan
MYSQL_PASSWORD=********
I get this error
error 20-Nov-2019 13:47:21 bash: -c: line 11: unexpected EOF while looking for matching ``' error
20-Nov-2019 13:47:21 bash: -c: line 37: syntax error: unexpected end of file
How can I ensure that variables are safely substituted in deployment (and, presumably, build) plans and ensure they are not interpreted?
Of course, I could create only alphanumeric passphrases, but that reduces entropy somewhat and I don't want to limit our infrastructure configuration. Do I need to use Bamboo Specs or something?
We're running self-hosted Bamboo version 6.3.4 build 60309 - 24 May 18
Hi @Michael
Thank you for raising this question.
Global, plan and deployment variables can be evaluated in tasks by using the following format:
${bamboo.<variableName>}
Please notice that this evaluation takes place before the task is executed.
Let's suppose you are adding the following line in your inline script:
VAR1=${bamboo.myVariable}
Before bash is called the variable is already substituted and you have the error mentioned.
...bash: -c: line 11: unexpected EOF while looking for matching...
How to avoid this?
Use a different variable formating.
We have two ways to mention a variable:
${bamboo.<variableName>}Evaluated before the build
$bamboo_<variableName>Available only when the bash script is run
How to move forward?
Please use the second format in inline scripts. It will prevent anomalies caused by strange characters that may be part of your variables.
Another option is to make sure the content of your variables is surrounded by single quotes ( 'content' ).
I hope that helps
It does; thank you!
One clarification: how should I use Bamboo variables that have dots in their names, like `bamboo.deploy.environment` ?
$bamboo_deploy_environment
or
$bamboo_deploy.environment
?
Presumably I should convert all `.` to `_` ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, convert all of them to underscores "_".
You should be able to see all the variables available in your build log file.
Try to search for one that you know and you should find all of them together.
=]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.