Bugzilla is well known bug tracking software. I would like to show simple solution on how to implement automatic submitting of uncaught exceptions (caused or somehow connected with our code) to company Bugzilla system.
Server side
First thing we need is a small utility script called bugzilla-submit which can be found in BUGZILLA DIRECTORY/contrib/bugzilla-submit folder. It's simple command line interface for submitting new bugs. This script reads .netrc file in the home directory (/var/www in our case) which must contain bugzilla system credentials:
machine "http://bugzilla.our-company.com"
login <an email address of bugzilla user>
password <password>
Second thing we need is to create a simple php script that will live on some publicly accessible server and will process POSTed bugs and submit them using the mentioned utility into bugzilla server (which may or may not be on the same machine). Basic skeleton of such script:
As you can see, the script is very simple as it allows only bug description to be modified (by our Eclipse plugin reporting system) and other fields are hard coded. It also isn't secured in any way so anyone who knows URL of the script (and guesses the format of POST request) can submit bugs!
There are many possibilities of how to secure it (e.g. some kind of one time passwords, https, limiting the number of allowed submit from one IP address etc.).
Client side
The third (and last) thing is the code in our Eclipse plugin that handles exceptions and asks user if he wants to report them. We do this simply by listening to workspace log events and reporting (or asking user if he wants to report) if one of the following conditions holds:
- The plugin where an error occured is ours
- The exception stacktrace contains our class
We consider plugin or class "ours" if its name starts with "com.our-company.productname". The following code must be run at startup (see how to do it):
And that's probably all
I just want to share the tool we’re using for tracking bugs http://www.wrike.com. The tool allows you to send screenshots to your team and get them in to your bug fixing plan at the same time. It’s all done via emails. Saves tons of time!