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 Bamboo environment results from REST API

These are the steps you can use to get the environment results of a deployment. You just need to know the plan-key associated with that deployment.
Ok, you will also need Curl, jq (command-line JSON processor) on a Unix like terminal.

  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[] | "\nCreator: " + .deploymentVersion.creatorDisplayName + "\nBranch: " + .deploymentVersion.planBranchName + "\nDeployment State: " + .deploymentState + "\nLife Cycle State: "+ .lifeCycleState'

    With the last request, you can get whatever information is available in the main rest, by adjusting the jq query set throught the pipe. In this example, it was configured to provide the creator, branch, and statuses of the given environment.
    Creator: <USER>
    Branch: <BRANCH>
    Deployment State: <DEPLOYMENT_STATE>
    Life Cycle State: <LIFE_CYCLE_STATE>

    e.g.

    Creator: admin
    Branch: master
    Deployment State: SUCCESS
    Life Cycle State: FINISHED

 

0 comments

Comment

Log in or Sign up to comment
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...

288 views 0 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