3

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.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Cade Roux
  • 88,164
  • 40
  • 182
  • 265
  • can you clarify what you mean with trac not being public? Does that mean your buildserver cannot connect you your trac? – wimh Aug 13 '12 at 21:11
  • @wimmel It requires password authentication with Trac's forms system. – Cade Roux Aug 13 '12 at 21:18
  • Can you create an account within Trac that you can use for the release notes? – Josh Laase Aug 14 '12 at 01:50
  • @JoshLaase Yes. I am creating a read-only account in Trac. Then I will write a script to logon to the web interface using curl and request the RSS. I have not yet found an easier way. – Cade Roux Aug 14 '12 at 03:00
  • What programming languages do you have the ability to use as part of the extraction of release notes? Are you able to use C#, python or Ruby? I have done a similar process of automating the extraction of tickets using C#. If you want, I can put down all of my steps and links on how I did this. – Josh Laase Aug 14 '12 at 13:08
  • @JoshLaase That might be useful - our application is a C# application, but we can use what we have to to help automate the build. Our Trac/SVN installation is hosted by a third-party, FWIW. – Cade Roux Aug 14 '12 at 14:39
  • Last question. :-) Does your host allow the XMLRPCPlugin (http://trac-hacks.org/wiki/XmlRpcPlugin)? If so, I will put together my notes and post them. – Josh Laase Aug 14 '12 at 15:07
  • @JoshLaase Looks like it's already installed but none of the components are enabled. Looks like trac-hacks is down until the end of the month, though. – Cade Roux Aug 14 '12 at 15:15
  • Typically a Trac installation with forms auth uses AccountManagerPlugin and it enables XmlRpc access using the HttpAuthPlugin. The paths parameter of [httpauth] specifies that the XmlRpc paths will cause a browser-type authentication challenge which works well with XmlRpc clients. If your resource (RSS) does not match the XmlRpc paths it may have trouble being retrieved by the client. There is a patched HttpAuthPlugin which allows an API client to specify a querystring to identify itself as an API client - see http://www.fat-bug.com/tracauth - look for the ZIP. This might help you. – Craig A Aug 14 '12 at 18:43
  • @CraigA 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. – Cade Roux Aug 14 '12 at 18:55

1 Answers1

1

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:PassWord@trac.myserver.com/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.

bta
  • 43,959
  • 6
  • 69
  • 99
  • http://stackoverflow.com/questions/7689637/is-it-possible-to-generate-a-changelog-automatically-from-trac – gavenkoa May 31 '14 at 21:28