4

I need to retrieve the Build Status from TeamCity in the form of XML, RSS format would be ideal.

I am familiar with the RSS feed within Teamcity but that is of no use as it is more of a history view. I am looking for something more like the page generated by the Status Widget but in XML form. (FYI, the status widget page is not XHTML - tried that!)

I wonder if anyone has across anything that could assist?

Kind Regards, David Christiansen

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
David Christiansen
  • 5,869
  • 2
  • 36
  • 42

6 Answers6

2

I've been working on this problem for a little while now

Here's a post showing you how to login to teamcity in code in c#

then its just a matter of using HTMLAgilityPack to look at the table.

if you turn on guest access its even easier. I'm cleaning up the code for release shortly if that helps. If your developing in another language I can help there too.

Community
  • 1
  • 1
Scott Cowan
  • 2,652
  • 7
  • 29
  • 45
2

You can use the Syndication Feed tool under My Settings And Tools to generate an RSS URL (Documentation here), and track changes versus build results to determine the status (i.e. building, and previously succeeded/failed)

As an example, I've just created this URL to view the last 5 build results:

http://teamcity:8111/feed.html?buildTypeId=bt2&itemsType=builds&itemsCount=5

Where:

  • buildTypeId is the ID of the configuration (get it by inspecting the URL of the build)
  • itemsType could be 'builds' or 'changes' or both

You could use the 'changes' type to determine if a build is currently in progress...

There are additional URL options for TeamCity RSS here, such as buildStatus and sinceDate.

Note: Depending on whether you have enabled guest access, you may need to use different contexts, such as /httpAuth/feed.html or /guestAuth/feed.html.

brasskazoo
  • 76,030
  • 23
  • 64
  • 76
1

Edit: as you point out, the RSS feed from TeamCity only includes completed builds.

One possibility would be to grab the HTML from the project you're interested in's details page, and then pull the current status from the top entry in the table of builds there.

Another option: have you considered using the Jabber or email notification system? It has more fine-grained event notification:

  • build starts
  • build succeeds or fails

both generate notifications, from which you can infer build status. Automation around email is straightforward, and Jabber is an open standard so I imagine this is reasonably easy too.

Any of these options would need a little wrapping code to convert to RSS.

Dan Vinton
  • 26,401
  • 9
  • 37
  • 79
  • Thanks for your response, however, the RSS option in "My Settings and Tools" displays historical information - not a 'Current Build Status' which is what I am looking for. – David Christiansen Dec 11 '08 at 11:46
1

Probably it is better to write your own plugin. If you know Java of course. You can create custom web controller and bind it to the url you like, this controller can accept buildId parameter, search for a build (SBuildServer.findBuildInstanceById()) and output XML.

Take a look at HelloUserController.java which is in the samplePlugin.zip bundled with TeamCity (TeamCity/devPackage).

Also its worth to check sources of some of the TeamCity plugins: http://www.jetbrains.net/confluence/display/TW/TeamCity+Plugins

Pavel Sher
  • 2,201
  • 14
  • 14
0

I did it using the API per buildtype:

curl -k "https://${SERVER}/guestAuth/app/rest/buildTypes/${BUILDTYPE}/builds/?locator=lookupLimit:1"|xpath -q -e //build/@status
Alfons
  • 511
  • 4
  • 17
0

Does this summary of a standard XML status format describe what you mean? I'm pretty sure TeamCity can produce this format, but not exactly sure how. Hudson does it with a URL like http://my.hudson.server.example.com:3030/cc.xml.

Douglas Squirrel
  • 2,304
  • 2
  • 19
  • 23
  • The first link does work for me. The second link is an example to show you the form of status links. It's not supposed to work. (URLs ending in example.com are always examples. Just visit one, e.g. http://example.com, for further explanation.) – Douglas Squirrel Nov 21 '09 at 14:50