escape variables in bamboo custom commands?

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

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

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/

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

 

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

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 Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

631 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot