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 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 Data Center Apps Program coming soon

G’day Bamboo customers, As we approach GA for Bamboo Data Center , we would like to inform you that the Data Center Apps Program for Bamboo starts this quarter. How long does it take? We are g...

83 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