Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to get the Build Number of another plan?


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.


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:
  • Or even (not desired for you) REST API:

    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.

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

Atlassian Community Events