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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,458,742
Community Members
 
Community Events
176
Community Groups

Password variable contains backticks, substitution fails in deployment plans

Edited

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

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 

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

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

Atlassian Community Events