Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Wednesday, September 12, 2012

Hooking up Pivotal Tracker to Google App Engine for java

Though this post is no where related to ADF but I dont want to create a new blog for just one post. Sorry for that !


Pivotal Tracker is an amazing agile development supporting bug/feature/story tracker system well suited for fast result oriented developments. We at Sakshum recently started using it for our development environment. Sakshum web application is hosted on Google's amazing cloud platform called Google App Engine . A natural requirement came up to be able to create stories to pivtoalTracker from google app engine when exceptional situations occur time to time. PivotalTracker's api page list only curl commands to show how a HTTP request may work to do that. We struggled quite a bit to make it work and thought to put the code here for the people who might be facing the same problem.



String pivotalUrl = "http://www.pivotaltracker.com/services/v3/projects//stories"; 
  String body = "bug" + storyTitle + "" + storyDesc + "TEAM MEMBER NAME ";

  try{
  URLFetchService fetchService = URLFetchServiceFactory.getURLFetchService();
    HTTPRequest request = new HTTPRequest(new URL(pivotalUrl), HTTPMethod.POST,  FetchOptions.Builder.withDeadline(30));
    request.addHeader(new HTTPHeader("X-TrackerToken","YOUR TOKEN"));
    request.addHeader(new HTTPHeader("Content-type","application/xml"));
    request.setPayload(body.getBytes());
    HTTPResponse response = fetchService.fetch(request);

    if (response.getResponseCode() != 200) {
    log.info("Could not create story as response code is:" + response.getResponseCode());
    }    
  }catch(Exception e){
  e.printStackTrace();
  }


Make sure to have the TEAM MEMBER NAME a valid team member in the pivotal tracker else this wont work at all.

PivotalTracker api page for reference is here

No comments: