Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Password variable contains backticks, substitution fails in deployment plans

Michael November 20, 2019

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

1 answer

1 vote
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 22, 2019

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:

  1. ${bamboo.<variableName>}
    Evaluated before the build
  2. $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 

Michael December 18, 2019

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 `_` ?

Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 18, 2019

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.

=]

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events