Cade Roux
Cade Roux

Reputation: 89651

Automatically Generating Release Notes from Trac

One of our web apps is deployed to a number of different servers for access by users at that site. We use Trac to manage the bugs/work items, but we're looking for a way to automate the release notes so that users whose server is upgraded will see a little notification about when they received their upgrade and a way to browse some kind of document - HTML or XML - which was extracted from Trac at the time of the build with all the items.

Ideally, we would have a post-build step which would extract from Trac the RSS XML based on the version x.y.z from the main assembly, save it as releasenotes.xml which after deployment with the binaries, templates etc will reside in production.

The web server then can display it within its installation.

My problem is that our Trac is not public (not even to all these users who don't have accounts in Trac, otherwise, we could point them at reports in Trac and they could log in as themselves to read them) and we can't automate this extraction because it requires a forms authentication process - I can't find a readonly RSS feed which doesn't require authentication.

Anyone solve that problem? Or is there another approach I should consider?

I currently having it working with curl and grep in a command script. I get the token from the login page, then login to get authentication cookies and then pull the RSS for the desired report. Obviously this is sensitive to the user/password/__FORM_TOKEN structure of the login form.

Upvotes: 3

Views: 698

Answers (1)

bta
bta

Reputation: 45057

Most likely, the XMLRPC plugin will be your friend here.

Trac-hacks is down at the moment so the full documentation isn't currently available, but here is a short Python script that might get you started (handling errors and invalid input is left as an exercise to the reader).

#!/usr/bin/python
# Fetch a Trac page via RPC
# Usage: fetchpage.py <wiki page name> <output file>

import sys
from xmlrpclib import ServerProxy

# Extract info from CLI args
page_title = sys.argv[1]
output_filename = sys.argv[2]

# Authenticate with Trac and fetch the specified wiki page
p = ServerProxy('http://UserName:[email protected]/login/rpc')
page = p.wiki.getPageHTML(page_title)

# Write page to file
with open(output_filename,'w') as outfile:
    outfile.write(page)

After executing the script with "./fetchpage.py 'ReleaseNotes/x.y.z' changelog.html", the file changelog.html will contain the content of the specified wiki page, pre-rendered into HTML. The toolbars and page header/footer are not included.

This assumes that you have a wiki page named ReleaseNotes/x.y.z that contains the release notes for the x.y.z release. Personally, I've found it easier to use a wiki page to create a release notes document (using macros) than to parse the RSS and do it manually. You can take this output, embed a CSS stylesheet into it, and have an attractive-looking changelog in HTML format that's ready to be distributed to users.

Note that the account being used here will need the XML_RPC permission in addition to the normal set of permissions for read access.

Upvotes: 1

Related Questions