Missed Team ’24? Catch up on announcements here.

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

Access rest api from within build?

Casey Harford August 17, 2012

Suppose I need data from the following rest call:

http://mybamboo:8085/rest/api/latest/result

If I use my browser, I can login to Bamboo, and then this call works, otherwise I get an authorization error. This is expected. However, i'm trying to get data from this rest call inside of a python script, which will be running in a Bamboo build plan.

I found a way to pass my username/password in the URL, but that seems insecure. Is there a way to accomplish this with Oauth or some other method that is secure? I was viewing the svn post commit script provided by Bamboo, which is simply a rest call, how is it authenticating?

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
Casey Harford August 23, 2012

I ended up with a solution using OAuth. In a nutshell, i've created an Application link for a "Generic Application" and used a set of rsa keys to perform the authentication. I found this excellent resource, which provides several examples of using OAuth with Atlassian applications(I followed the python example):

https://bitbucket.org/rmanalan/atlassian-oauth-examples

0 votes
Norman Abramovitz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 17, 2012

If you really have concerns you can setup Bamboo to use SSL and do your requests using https. That is the secure way to do things.

It is unclear what you are trying to accomplish but here are a couple links that might be related to your issue.

https://confluence.atlassian.com/display/BAMBOO/Running+Bamboo+over+HTTPS

https://confluence.atlassian.com/display/BAMBOO031/Configuring+OAuth+Consumers

Casey Harford August 19, 2012

Hopefully this will clear things up:

I currently have a python script, which accesses the bamboo rest api. I have this script setup in a task in Bamboo. It works fine, with basic http authentication, but this requires that my user name/password be stored in the script. I'm looking for a way to authenticate for rest calls, without using my username/password. Possibly a public/private key method? OAuth looks like it would work, but the guide for setting it up is for other apps like Jira, not my own(script).

James Dumay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2012

There isn't a great way of soliving this at the moment. One way I can think of this working is have Bamboo expose a token during the build process that could be used by any script that wants to access the servers REST API. I've raised an improvement request to track this.

0 votes
tkhduracell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 17, 2012

Why don't you access the latest build result from within a task? What is your goal?

Btw
You can pass the credentials via POST and http-basic I think.

Casey Harford August 17, 2012

Thanks for the reply. My ultimate goal is go get a list of the latest build results(pass/fail), and push that data to Geckoboard. (geckoboard.com)

I see that I can pass credentials with http-basic, but that is insecure and would require my credentials be saved in a script. Is it possible to access latest build results from within a task?

TAGS
AUG Leaders

Atlassian Community Events