Does bamboo allow a plan variable to point to another variable referencing a system property?

Robins John
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 12, 2022

In my build script I am referencing a system variable gradle_home. I want to substitute this with a bamboo variable so that I can override this value for a specific branch. However the build runs on different systems and the only way to reliably get the gradle_home for the system is via the system.gradle_home. So I am trying to get the bamboo variable to point to the system variable in normal case and to the new path in the overridden case. Is this possible?

1 answer

1 accepted

0 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 13, 2022

Hello @Robins John

Welcome to Atlassian Community!

Choosing which variable to use is up to the application, not Bamboo. What you can do is set a script task that would evaluate if the custom variable is set and then overwrite the system.GRADLE_HOME if needed. You can do something like this:

Assuming:

  • ${system.GRADLE_HOME} (the one inherited from your OS)
  • ${bamboo.GRADLE_HOME} (the one declared on the Plan)

Add a Script task that will evaluate the variable and call Gradle:

#!/bin/bash

if [ -n "${bamboo_GRADLE_HOME}" ] ; then
export GRADLE_HOME=${bamboo_GRADLE_HOME}
fi

${GRADLE_HOME}/bin/gradle build

More information:

Cheers,

Eduardo Alvarenga
Atlassian Support APAC

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

Robins John
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 15, 2022

Thanks Eduardo. Your input certainly helped!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events