Blog




As we are planning to move from Bugzilla to JIRA, I investigated how to achieve that the static links are not broken.

All our Open Source products have static references to Bugzilla issues. For instance the release notes of smartics-jboss-modules-maven-plugin or smartics-properties.

Using the Apache Module mod_rewrite it is possible to rewrite requested URLs on the fly. This post addresses especially Apache 2.2.22 but should be quite similar with Apache 2.4.X though.

The task is now to rewrite e.g
https://www.smartics.eu/bugzilla/show_bug.cgi?id=931
to
https://www.smartics.eu/jira/browse/SJBMMP-19.

This could be done in writing a RewriteMap containing the Bugzilla issue ID as a key and the JIRA issue ID as the value. The next step after importing the Bugzilla issues to JIRA is generating such a map.
 
Use the External System Import feature to import the Bugzilla issues to JIRA: secure/admin/ExternalImport1.jspa

Each imported issue has (as you can see in the image) a field External Issue Id. This is in our case the old Bugzilla issue ID.

With some simple steps we export the imported issues to the map in a format we need:

  • Go to the newly imported project in JIRA
  • Change the displayed columns
  • Change the order of the columns using drag and drop
  • Export to Excel
  • Remove all unnecessary elements in the exported excel sheet and convert the links to plaintext
  • Export Excel sheet to text file

For our smartics-jboss-modules-maven-plugin the exported text file looks like this:

##
## bugzilla-jira-map.txt - Bugzilla to JIRA map (smartics-jboss-modules-maven-plugin)
##
806 SJBMMP-3
808 SJBMMP-4
809 SJBMMP-5
810 SJBMMP-6
811 SJBMMP-7
834 SJBMMP-8
837 SJBMMP-9
842 SJBMMP-10
843 SJBMMP-11
844 SJBMMP-12
845 SJBMMP-13
848 SJBMMP-14
851 SJBMMP-15
873 SJBMMP-16
874 SJBMMP-17
875 SJBMMP-18
931 SJBMMP-19

Having this we are nearly finished. The last step is to copy the generated file to Apache and to configure Apache to do the redirect:

...
# In the case you have to debug the rules
#LogLevel alert
#LogLevel info rewrite:trace6
#LogLevel alert rewrite:trace3
#OLD APACHE: RewriteLog "/tmp/rewrite.log"
#OLD APACHE: RewriteLogLevel 5
#The mappingfile (must not be in a Directory entry)
RewriteMap bugzillajiramap "txt:/etc/apache2/bugzilla-jira-map.txt"
...
#Our Bugzilla Directory entry
<Directory /home/smartics/public_html/bugzilla/>
   AddHandler cgi-script .cgi
   Options +Indexes +ExecCGI +FollowSymLinks
   DirectoryIndex index.cgi
   AllowOverride Limit
   AddType application/vnd.mozilla.xul+xml .xul
   AddType application/rdf+xml .rdf
   RewriteEngine on
# Grep the ID from the Query_String and store in Variable 1.
   RewriteCond %{QUERY_STRING} "id=(.*)$"
# Check if ID is in the specified text file. Only when found continue with RewriteRule.
   RewriteCond ${bugzillajiramap:%1|NOTFOUND} !NOTFOUND [NC]
   RewriteRule "^show_bug.cgi" "https://www.smartics.eu/jira/browse/${bugzillajiramap:%1|NOTFOUND}"
</Directory>

That's it! Restart Apache using apache2ctl restart and you successfully moved your Bugzilla project to JIRA.

Resources that helped me to solve this:



Link

Link

Posts