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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,555,661
Community Members
 
Community Events
184
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

1 vote
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 24, 2019 • edited May 27, 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