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 do I get release versions related to particular build with Bamboo REST API?

I need to know if build already has a release version and create one if it doesn't. How can I check it? 

1 answer

Hi @Дмитрий Григорьев

There is no easy way to get this information through REST API. What we could do is to get it directly from the Bamboo DB.

This query should give you the information you need:
⚠️ It was designed for Postgres DB and might need adjustments to work with a different database type.

WITH
    latest_builds AS
    (SELECT CONCAT(build_key, CONCAT('-',max(build_number))) build, plan_name
    FROM buildresultsummary
    WHERE build_type LIKE '%CHAIN%'
    GROUP BY build_key, plan_name),

    versions AS
    (SELECT CONCAT(dvp.plan_key, CONCAT('-',dvp.build_number)) build, dv.plan_branch_name, dr.deployment_state
    FROM deployment_version dv
    LEFT JOIN dep_version_planresultkeys dvp
      ON dv.deployment_version_id = dvp.deployment_version_id
    LEFT JOIN deployment_result dr
      ON dv.deployment_version_id = dr.version_id)

SELECT lb.*, v.plan_branch_name, v.deployment_state
FROM latest_builds lb
LEFT JOIN versions v
ON lb.build=v.build

Explanation

The first part of the query will list the latest builds from all plans.

    SELECT CONCAT(build_key, CONCAT('-',max(build_number))) build, plan_name
    FROM buildresultsummary
    WHERE build_type LIKE '%CHAIN%'
    GROUP BY build_key, plan_name

The second part will list all the builds that have versions, deployed or not.

    SELECT CONCAT(dvp.plan_key, CONCAT('-',dvp.build_number)) build, dv.plan_branch_name, dr.deployment_state
    FROM deployment_version dv
    LEFT JOIN dep_version_planresultkeys dvp
      ON dv.deployment_version_id = dvp.deployment_version_id
    LEFT JOIN deployment_result dr
      ON dv.deployment_version_id = dr.version_id

The third part will join the results of the queries above. It should give you a consolidated table with all latest builds with or without version/deploy.

I hope that will helps you to move forward.

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...

167 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