Trello is a pretty nice web site. It is (sort of) a kanban board that is very useful when organizing groups of people in situations where a full agile framework would be too cumbersome. Kanban is used a lot in IT Operations. If you want a great story on it, go check out The Phoenix Project.
One thing Trello is lacking, however, is the ability to tap into an RSS-style feed for one or more of your boards. But, where there is an API, there’s a way. This took me about 30 minutes to iron out, and is heavily borrowed from the basic example in the documentation for trello-rss.
Step One – Three-legged OAuth
Trello uses OAuth. So you will need to get your developer API keys from Trello. You will also need to get permanent (or expiring whenever you want) OAuth tokens from them. This process is a little cloudy, but I found a post on StackOverflow that got me over the hump.
Step Two – a little python
I created a little bit of python to handle this for me. Bear in mind it’s still VERY rough. My though is to start to incorporate other Trello automation and time-savers into it down the road. If that happens I’ll stick it out on github.
#!/usr/bin/env python from trello_rss.trellorss import TrelloRSS from optparse import OptionParser import sys class TrelloAutomate: ''' Used for basic automation tasks with Trello, particularly with CI/CD platforms like Jenkins. Author: jduncan Licence: GPL2+ Dependencies (py modules): - httplib2 - oauthlib / oauth2 ''' def __init__(self): reload(sys) sys.setdefaultencoding('utf8') self.oauth_token = $my_token self.oauth_token_secret = $my_token_secret self.oauth_apikey = $my_api_key self.oauth_api_private_key = $my_api_private_key def _get_rss_data(self): try: rss = TrelloRSS(self.oauth_apikey, self.oauth_api_private_key, self.oauth_token, channel_title="My RSS Title", rss_channel_link="https://trello.com/b/XXX/board_name", description="My Description") rss.get_all(50) data = rss.rss return data except Exception,e: raise e def create_rss_file(self, filename): data = self._get_rss_data() fh = open(filename,'w') for line in data: fh.write(line) fh.close() def main(): parser = OptionParser(usage="%prog ", version="%prog 0.1") parser.add_option("-r", "--rss", action="store_true", dest="rss", help="create the rss feed", metavar="RSS") parser.add_option("-f", "--file", dest="filename", default="trellorss.xml", help="output filename. default = trello.xml", metavar="FILENAME") (options, args) = parser.parse_args() trello = TrelloAutomate() if options.rss: trello.create_rss_file(options.filename) if __name__ == '__main__': main()
Step Three – Jenkins Automation
At this point I could stick this little script on a web server and have it generate my feed for me with a cron tab. But that would mean my web server would have to have to build content instead of just serving it. I don’t like that.
Instead I will build my content on a build server (Jenkins) and then move deploy it to my web server so people can access my RSS feed easily.
Put your python on your build server
Get your python script to your build server, and make sure you satisfy all of the needed dependencies. You will know if you haven’t, because your script won’t work. 🙂 For one-off scripts like this I tend to put them in /usr/local/bin/$appname/. But that’s just my take on the FHS.
Create your build job
This is a simple build job, especially since it’s not pulling anything out of source control. You just tell it what command to run, how often to run it, and where to put what is generated.
So using a little python and my trusty Jenkins server, I now have an RSS Feed at $mywebserver/trello.xml that is updated every 15 minutes (or however often you want).
Of course this code could get way more involved. The py-trello module that it uses is very robust and easy to use for all of your Trello needs. I highly recommend it.
If I have time to expand on this idea I’ll post a link to the github where I upload it.