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

How to change plan variable value on a script task?

Vazquez_ Eduardo August 20, 2023

I have a plan variable called myCustomVar="myvalue"

 

I can successfully use it inside my script tasks calling it ${bamboo.myCustomVar}, however I am looking to modify the variable's value in one of the tasks. I have tried the following with no success:

  1. bamboo.myCustomVar="newvalue"
  2. myCustomVar="newvalue"
  3. ${bamboo.myCustomVar}="newvalue"

I have been thoroughly seeking for an answer in documentation with no success, all I have found is that we can override variables in manual builds but this will not work for my purpose,

 

Thank you

1 answer

1 vote
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 20, 2023

Hello @Vazquez_ Eduardo

Welcome to Atlassian Community!

If you are looking to only modify the variable's value in one of your tasks you will have to do that on the command line during the task execution. Also, Script tasks in Linux use the ${bamboo_myCustomerVar} syntax (with a _ instead of dots .). As described here:

But if you want to have a controlled experience, you can add an Inject Bamboo Variables task that would create new variables based on property files which can be used subsequently by your builds.

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Vazquez_ Eduardo August 22, 2023

Thank you for your prompt response. It seems your first paragraph pretty much describes what I am trying to do with the only exception that my task script is run on windows, would this also apply? If so I am thinking the syntax would be one of the options below:

  1. bamboo_myCustomerVar="newValue"
  2. set bamboo_myCustomerVar="newValue"

The inject bamboo variables task sounds great but for now I think the solution above should suffice should you confirm the appropiate syntax for windows.

 

Best regards,

Eddie

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2023

Hello @Vazquez_ Eduardo

If you are using Windows, there's no need to replace the dots with underscores. So the "set" command will work as required with the variables set as bamboo.myCustomerVar.

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Like Steffen Opel _Utoolity_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events