Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 variables in an app's code

In my app that's being built on Bamboo, I have the following code:

"build-aem": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "mvn --batch-mode release:update-versions -DdevelopmentVersion=${bamboo.buildNumber} -f ./apps/americas-aem/pom.xml"
},
{
"command": "mvn clean install -f ./apps/americas-aem/pom.xml"
}
],
"parallel": false
}
}

 What I'd like to happen is for the "${bamboo.buildNumber}" to be replaced with the actual Bamboo variable, as shown on this page:

https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html#Bamboovariables-Build-specificvariables

 

Do you know of a way to make this happen?

1 answer

1 accepted

1 vote
Answer accepted

Hi @Samuel VanFossen , welcome to Atlassian Community!

All bamboo variables are accessible using ${bamboo.<variablename>} in configuration, or ${bamboo_<variablename>} in scripts.

tick In your specific case with NPM you should use system variables (scripts) instead, as Bamboo variables are not accessible within that node workspace.

As documented in System variables - Using variables in bash, you should:

Using variables in bash

Bamboo variables are exported as bash shell variables. All full stops (periods) are converted to underscores. For example, the variable bamboo.my.variable is $bamboo_my_variable in bash. This is related to File Script tasks (not Inline Script tasks).

E.g. assuming you want to print Bamboo's bamboo.buildNumber with the following code:

"build-aem": {
  "executor": "@nrwl/workspace:run-commands",
  "options": {
    "command": "echo This is my Bamboo Build number: ${bamboo_buildNumber}"
  }
}

and your bamboo.buildnumber = 123 -- it will produce the following output:

12-May-2021 12:26:20 
12-May-2021 12:26:20 > bamboo@0.0.0 nx /home/bamboo/bamboo-agent-home/xml-data/build-dir/MFP-MVFP-JSJ
12-May-2021 12:26:20 > nx "build-aem"
12-May-2021 12:26:20
12-May-2021 12:26:21
12-May-2021 12:26:21 > nx run bamboo:build-aem
12-May-2021 12:26:21 This is my Bamboo Build number: 123
12-May-2021 12:26:21
12-May-2021 12:26:21 ———————————————————————————————————————————————
12-May-2021 12:26:21
12-May-2021 12:26:21 > NX SUCCESS Running target "build-aem" succeeded

Additionally, if your code already contains specific variables that are meant to be portable and/or you cannot amend it with the the bamboo_ prefix, you can alternatively declare a value for those variables under Advanced Options -> Environment Values -- this time using bamboo variables, E.g.:

In Advanced Options -> Environment Values:

BUILD_NUMBER=${bamboo.buildNumber}

In code:

"build-aem": {
  "executor": "@nrwl/workspace:run-commands",
  "options": {
    "command": "echo This is my Bamboo Build number: ${BUILD_NUMBER}"
  }
}

Thanks! This worked for me.

Like Eduardo Alvarenga likes this

Suggest an answer

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

Bamboo Data Center - Early Access Program

G’day Bamboo customers, The wait is almost over! We are in the final stages of work on the first release of Bamboo Data Center, our self-managed enterprise offering of Bamboo. This Data Center offe...

1,117 views 0 16
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