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,364,806
Community Members
 
Community Events
168
Community Groups

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

Atlassian Community Events