I had a need to print the build status of our teamcity server in trac. After researching various solutions, I figured a trac macro would best fit. It was a surprisingly simple solution so I figured I would share it here.
I created a file called “TeamCityStatus.py” and placed it into my trac/plugins folder.
from urllib import urlopen
from trac.wiki.macros import WikiMacroBase
“””Inserts the current build status into the wiki page.”””
def expand_macro(self, formatter, name, args):
Obviously change the URL open line to match your teamcity installed location.
Then inside any wiki page on your trac site, just place the macro command “[[TeamCityStatus]]”. You should be good to go!