Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

223 views 4 6
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