This script is to be used to post comment updates to ZenDesk tickets as part of your post-commit hook in subversion. It’s written in PHP and requires the SimpleXML package along with cURL to be enabled for PHP.
The script itself can live anywhere, but it will work if you simply put it in the ‘/path/to/repository/hooks/` folder (e.g. `/home/subversion/MyRepository/hooks/zendesk-svn/`). Your post-commit hook needs to be made executable (`chmod +x post-commit`) or your subversion client will complain that the post-commit hook failed.
./MyRepository - hooks/ - post-commit - zendesk-php/ - zendesk-svn.php
You will need to rename/copy config.inc.php.dist to config.inc.php and update the settings within before using this script.
You can run the script from the command line to test a particular commit against the parsing logic (and to ensure that it is integrating properly with ZenDesk).
/usr/local/bin/php /path/to/zendesk-php/zendesk-svn.php 1234
Where ‘1234’ is the particular revision you want the script to parse.
-
PHP 5.3.x or higher
-
libxml2 (for XML parsing)
-
cURL (with SSL support)
-
OpenSSL (for cURL)
With the post-commit hook properly installed and the script configured, you should be able to use the key words “ticket”, “fixed”, “fixes”, “addresses”, “addressed” in your commit message followed by a “#{ticket_id_number}” to update the status of tickets in ZenDesk.
These would work:
Ticket #2340 is fixed with this change. Updated the header to include the new logo. Addresses #1258. Fixed #3456 by re-factoring the navigation panel. Corrected spelling on home page. Addresses #1258 and addresses #1259 <-- this would post to both tickets Corrected spelling on home page. Addresses #1258 and #1260 <-- this only posts to the first one (missing keyword)
These would not work at all:
Fixes for #1254 by resetting the password. <-- keyword must be immediately before the # sign Addressed # 1255 with new layout. <-- the space causes the ticket ID to not be recognized
This script assumes that your usernames in Subversion neatly correspond to your e-mail addresses in ZenDesk (jdoe in subversion is [email protected] in ZenDesk). If they don’t, the updates will not be properly attached to your “Agent” account, and might be outright rejected.