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
4,363,252
Community Members
 
Community Events
168
Community Groups

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

Atlassian Community Events