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

How to add label to build or plan using bamboo rest api

Tomasz Pawlak
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2015

No ideas left.

When I'm setting up request header field content-type to application/xml and setting proper content-length I'm recieving bad request 400 status code. Are there any special/mandatory fields need to be used for POST ?

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2015

Hello Tomasz,

Just tested adding of build label by rest API at latest Bamboo 5.7.2

Used Chrome extension Simple REST Client

URL: http://localhost:6990/bamboo/rest/api/latest/result/BB-MR-2/label

Method: POST

Headers: 

  • Content-Type: application/xml
  • Accept: application/xml

Data: <label name="xml_label" />

It requires authentication, so at first I logged in as admin at other tab. 

Submitted result, received response 204. Refreshed build list and found that build #2 of MR plan has "xml_label" label.

Please let me know if you receive another result.

4 votes
Krystian Brazulewicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2015

I'd like to add commandline example to what @Alexey Chystoprudov wrote:

curl -X POST --user admin:admin -H "Content-Type: application/json" -d '{"name":"new-label"}' http://localhost:8085/bamboo/rest/api/latest/result/FOO-BAR-2/label

I also suggest to always use JSON format which is lighter than XML

Atul Bhingarde January 23, 2018

It worked fine, but only for static strings, I had hard time with the variables

Atul Bhingarde January 24, 2018

I found a solution -d '{"name":"'"$VAR1"'"}' works for the variables.

Now I am finding that the label is changed to lower case, searching for the solution :) 

0 votes
Tomasz Pawlak
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2015

It's working. Thanks guys. Looks like the crucial field for header is "Accept". Without it didn't work.

TAGS
AUG Leaders

Atlassian Community Events