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

How to get deploymentResultId using REST API?

Dmitrij Kultasev May 31, 2019

How can I get deploymentResultId for specific deployment?

1 answer

1 accepted

1 vote
Answer accepted
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 3, 2019

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.

Dmitrij Kultasev June 10, 2019

@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

Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 10, 2019

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.

Dmitrij Kultasev June 11, 2019

yes, that works. Sorry.

Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 11, 2019

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

Atlassian Community Events