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

escape variables in bamboo custom commands?

DO NOT USE Rob Biggs January 21, 2016

This question is in reference to Atlassian Documentation: Bamboo variables

Does anyone know how to escape a variable on a custom command? For example, I want to use ${PWD##*/}, which will get me the working directory without the path. This works on the command line but not when parsed through the bamboo interpreter since it matches the format bamboo uses for variables. 

1 answer

0 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2016

Hello Rob,

Thank you for your inquire.

Could you provide us with an example to the "custom command" so we can evaluate the way ${PWD##*/} is being executed, please?

Kind regards,
Rafael P. Sperafico
Atlassian Support

DO NOT USE Rob Biggs January 21, 2016

Have /bin/mv added as a custom exe on the server & trying to do something like...

/bin/mv this.tar.gz /opt/atlassian/bamboo/home/xml-data/builds/${PWD##*/}/download-data/build_logs/
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2016

Hello Rob,

I have just test it using the following and the build ran successfully, mostly important, the file has been moved to the destination directory:

#!/bin/bash

echo ${PWD##*/}

/bin/mv "foo.txt" "/opt/atlassian/home/atlassian-bamboo-5.10.0/xml-data/builds/${PWD##*/}/download-data/build_logs/"

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

 

DO NOT USE Rob Biggs February 5, 2016

Can you confirm that Bamboo uses /bin/bash and NOT /bin/sh?

DO NOT USE Rob Biggs February 5, 2016

I have confirmed that bamboo uses sh when executing scripts, though if you setup the script as a command it runs it via bash

sh does not allow for array processes. this is an odd limit to impose.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events