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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to use bamboo variable inside of executable?

I have an executable that I want to share across all agents that simply references a global bamboo variable in the path like ${bamboo.myPath}\bin\prog.exe, myPath is defined in my global variables inside of bamboo but when the command runs, it's not replacing ${bamboo.myPath} with my global variable? Is it possible to use global variables in the definition for executable paths?

2 answers

1 accepted

1 vote
Answer accepted

Hi @Charles Patton Jr,

If your variable is correctly declared this should work for you (assuming you are on windows):

%BAMBOO_MYPATH%\bin\prog.exe

Variables should be referenced in a different manner when used on terminal or scripts. Please take a look at the comment below that should be also visible in the global variables page:

For task configuration fields, use the syntax ${bamboo.myvariablename}. Bamboo also supports nested variables. For instance, if you set variableName = world, and variable.value = Hello ${bamboo.variableName}, Bamboo will resolve it as Hello world. For inline scripts, variables are exposed as shell environment variables which can be accessed using the syntax $bamboo_MY_VARIABLE_NAME (Linux/Mac OS X) or %BAMBOO_MY_VARIABLE_NAME% (Windows).

Please let us know if that resolves the issue.

I tried a few different versions of the environment variable structure you listed, like %BAMBOO_MYVARIABLE%, %bamboo_myvariable%, %bamboo_my_variable% and none worked.

Each time I can see in my logs it's unable to resolve because it's not actually placing my global variable into the command.

Is there some guidance as to how the spaces are determined in the variable name? Could that be my problem?

Please let me know if there's more information I could provide.

Can you try this in your script task?

echo dir > dir_command.bat
%bamboo_working_directory%\dir_command.bat

⚠️Please make sure you set the interpreter to "shell" or "bin/sh or cmd.exe".

 What are the results you get?

Just to clarify this was not with a script task. This is in the global executable where it simply asks for a path.

Can you tell me how the command failing is called?
What is the task involved?

I also fumbled with this as documentation is not specific (or may even be considered misleading.)

For the question -

   "Is it possible to use global variables in the definition for executable paths?"

The answer is no, bamboo variables cannot be used when defining a command task's executable path. Instead, a script task must be used.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

573 views 1 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you