Exporting Redmine issues and then importing them to a SourceForge project

I had 60-something Issues in a Redmine installation that I managed myself that I wanted to import into a new SourceForge project. Redmine has native support to export these issues into a CSV file. It turns out that CSV is mildly richer than I had previously thought, and cleanly supports things like a single “cell” in the resulting spreadsheet containing a large, multi-line description full of quotes and commas.

The SourceForge API v2.0 Beta is scriptable. Awesome. The example at that page uses Python, and I like Python, so we’re good. The steps are roughly as follows:

  • Create an “oauth application” in your SourceForge account here. You will end up with a key and a secret from the registration process, which you will need to paste into the relevant scripts.
  • Thanks to the existing SourceForge example, the scripting related to Oauth login was already done for me. Note that webbrowser.open() is used to allow you (the human) to manually copy/paste a per-session PIN. Your OS needs to support the launch of a web browser. Mine (Ubuntu 10.04) did without issue.
  • Use the Python CSV package to parse the Redmine-exported CSV file into a Python data structure (roughly an array of dict objects, but see DictReader.fieldnames to understand how it is more than that).
  • Add some custom scripting to map Redmine fields to supported SourceForge fields. A few fields map in a sensible way. The rest I just inserted with a descriptive prefix at the beginning of the primary Ticket Description.

I placed the scripts on github (no, the irony is not lost on me, but my current preference is for long-lived things to be on SourceForge and quick-and-dirty things to be on github).


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s