TeamCity build status icon

Posted on by Evgeny Goldin

With the upcoming version of TeamCity 7.1, it is now easier to get status updates on a build, by using TeamCity’s HTTP API . We have had this functionality in the past, however it hasn’t been straightforward to use and not the most ideal solution for things like markup pages.

With 7.1, which is currently in EAP we have simplified this. The following single line of code:

<img src="http://evgeny-goldin.org/teamcity/app/rest/builds/buildType:(id:bt54)/statusIcon"/>

produces the status icon for the “rest-clients” project:

The only thing you need to know about the project is the build configuration ID, which is always accessible in the URL address bar

Build Configuration id

If a build is not successful, you’ll see:  or 

The code required is:

<a href="http://teamcity/viewType.html?buildTypeId=btN&guest=1">
<img src="http://teamcity/app/rest/builds/buildType:(id:btN)/statusIcon"/>
</a>

Don’t forget to add the “guest=1” parameters to the URL so that people clicking on the link will be taken directly to the build page. Otherwise they’ll be welcomed with a login screen. See it in action on GitHub. For more details about the options available, see the documentation page.

Happy green builds!

banner_blog@2x

Comments below can no longer be edited.

7 Responses to TeamCity build status icon

  1. Tadek says:

    July 31, 2012

    Guys,

    First of all it’s great !
    One thing I’ve noticed is that github changes and caches url when referencing non https images, so build status is cached ;/ To avoid that Teamcity needs to be configured to use https.

    Cheers,
    Tadek

  2. Carl says:

    November 13, 2013

    What about a last built date that could be returned? Is that possible?

    • Maximilian says:

      August 30, 2014

      Yes, that would be awesome and the latest build number would be cool as well. And maybe artifacts?

  3. Jmaxxz@jmaxxz.com says:

    January 28, 2014

    What about a code coverage badge? Similar to coveralls.io?

  4. Maximilian says:

    August 30, 2014

    This is great! Note that guest login has to be enabled, otherwise it will show “no permission” in the icon.

  5. blicket says:

    January 13, 2015

    I second code coverage badge! Please make it happen captain.

  6. Displaying Team City build status in Octopus Deploy – Mexia says:

    April 6, 2017

    […] a build status icon to display on a webpage. It has been around for a little while as there was a blog post by JetBrains back in 2012 about it! So now when we look at our Projects page we see something […]

Subscribe

Subscribe for updates