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

How to use bamboo variable inside of executable?

Charles Patton Jr January 28, 2019

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
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 30, 2019

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.

Charles Patton Jr January 31, 2019

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.

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

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?

Charles Patton Jr January 31, 2019

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

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

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

0 votes
john livingston April 27, 2020

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
AUG Leaders

Atlassian Community Events