Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I get release versions related to particular build with Bamboo REST API?

Дмитрий Григорьев
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 22, 2019

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

1 vote
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 24, 2019

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
AUG Leaders

Atlassian Community Events