Expose EC2 instance metadata in Bamboo build

I'm using Bamboo cloud to run a maven build on an EC2 instance.

Some of the tests require the local ip address of the instance. Of course, I can hard code that as either an environment variable or a system property in my build plan. However, this doesn't work well if the instance were to crash.

Luckily, Amazon provides the metadata service that allows me to get this value dynamically from any EC2 instance:

/usr/bin/curl http://169.254.169.254/latest/meta-data/local-ipv4

So essentially, I just want to execute that one line and place the resulting value in either an environment variable or a system property that can be used within my build plan.

I've read the Bamboo documentation up and down and tried several approaches (setting global variable, exporting environment variable in instance startup script, setting Maven environment variable in build plan, executing a script task), but none of them have worked.

Is there a way to do this that I'm missing?

1 answer

1 votes

You can create a script task that will output the required data into a file and then use the variable inject task to feed them into Bamboo.

Suggest an answer

Log in or Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,080 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot