Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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 get the Build Number of another plan?

Hi

Is there a way to get the build number of another plan? 

Would be best if I could just reference it as a bamboo variable in my current plan, not with an REST API call, just like TEAMCITY.

https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html

Thanks.

1 answer

1 accepted

0 votes
Answer accepted

Hello Niko,

I have the impression that it can only be achieved in TeamCity when using a snapshot dependency (Using the Build Number of another Configuration – TeamCity Support).

I'm not sure if this is the same idea (I don't work with TeamCity), but in Bamboo we have the plan build dependencies (Setting up plan build dependencies - Atlassian Documentation) to set relationship between plans. Although we have that, variables cannot be passed from parent plans to child plans. We have a feature request to improve that ([BAM-3175] In order to have pass control to child build plans, Bamboo should have an option of passing variables between parent and child builds), but there is a workaround you can use.

If your plans have a dependency relationship you can do this:

  1. Create a variables file through a script task in your parent plan to export the variables you want in the child plan, e.g.
    echo "planKey="${bamboo.planKey} >> variables
    echo "buildNumber="${bamboo.buildNumber} >> variables
  2. Create an artifact definition to publish this file
  3. Download the artifact in the child plan
  4. Add an inject variables task to load the variables in the child plan

The process above can be used to get any variables from the parent plan and publish them in the child plan.


You can also:

  • Get the latest build number from the DB:
    SELECT MAX(BUILD_NUMBER) FROM BUILDRESULTSUMMARY WHERE BUILD_KEY='<PLAN-KEY>'
  • Or even (not desired for you) REST API:
    <Bamboo_URL>/rest/api/latest/result/<PROJ-KEY>-latest

    Linux example:

    curl -u <USER>:<PASSWORD> -X GET '<Bamboo_URL>/rest/api/latest/result/<PROJ-KEY>-latest' | awk -v FS="(resultNumber)" '{print $2}' | tr -d '<>/'

I hope it helps. 

Hi Daniel

Thanks for the reply. We actually implemented the solution you mentioned, exposing the build number as an artefact.

Glad to know that there is a feature request opened as this is a very useful function to have.

I have written a guide for others who might be interested.

https://medium.com/@niko.wah.hn/how-to-share-build-number-between-plans-in-bamboo-ci-f708d55483f1

Hi Niko,

I'm glad to know you already implemented it and thank you so much for writing the article and sharing it here =]


Suggest an answer

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

Bamboo Data Center 8.1 is now available

G’day Bamboo customers, Bamboo DC 8.1 is now available with it the following features and programs: SAML 2.0, OpenID Connect, and Crowd SSO In order to help admins with a simplified user manage...

149 views 0 4
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