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 to get deploymentResultId using REST API?

How can I get deploymentResultId for specific deployment?

1 answer

1 accepted

1 vote
Answer accepted

Hello @Dmitrij Kultasev

I hope you are doing great!

Let me share a couple of steps you can use to get this information knowing just the plan associated with a given deployment.

  1. Get the <PLAN_KEY> and run the following request:
     curl -u <USER>:<PASSWORD> \
    -X GET -p <BAMBOO_URL>/rest/api/latest/deploy/project/forPlan?planKey=<PLAN-KEY> \
    | jq -r '.[] | "Name: " + .name + "\tdeploymentId: " + (.id|tostring)'
    It should give you a result like:
     Name: <DEPLOYMENT_NAME>       deploymentId: <DEPLOYMENT_ID>
  2. Get the <DEPLOYMENT_ID> and run:
    curl -u <USER>:<PASSWORD> \
    -X GET -p '<BAMBOO_URL>/rest/api/latest/deploy/project/<DEPLOYMENT_ID>' \
    | jq -r '.environments[] | "Name: " + .name + "\tenvironmentId: " + (.id|tostring)'
     As a result, you should get:
     Name: <ENVIRONMENT_NAME>      environmentId: <ENVIRONMENT_ID>
  3. Following the same idea, get the <ENVIRONMENT_ID> and run:
    curl -u <USER>:<PASSWORD> \
    -X GET -p '<BAMBOO_URL>/rest/api/latest/deploy/environment/<ENVIRONMENT_ID>/results' \
    | jq -r '.results[] | "Version" + .deploymentVersionName + "\tdeploymentResultId:" + (.id|tostring)'
    This one should give you the deploymentResultId you need:
     Version: release-XX deploymentResultId: <ENVIRONMENT_RESULT_ID> 

    ⚠️Please notice that the above request use both jq (command-line JSON processor) to simplify filtering the results.

 

I hope that helps.

@Daniel Santos  that's not what I needed. That's the ID I'm looking for to be used in  /deploy/result/{deploymentResultId} .

I might go wrong direction, but I want to find last successful deployment for specific plan.

Screenshot_6.png

Hi @Dmitrij Kultasev

Please give the steps above a chance. They will give you exactly a list of deploymentResultIds for a given environment.

This is the relationship between the plan and a  given deploymentResultId:

  • Build plan >> Deployment Project Id >> Deployment Environment Id >> deploymentResultId

I just tested these steps again. They should give you exactly what you want.
Please let me know if you face any issues to follow them.

yes, that works. Sorry.

No worries, sorry for not being clear in my first message.
I see you in the next thread!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

622 views 1 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