Skip to content

Instantly share code, notes, and snippets.

@amackey
Created September 18, 2013 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amackey/6615429 to your computer and use it in GitHub Desktop.
Save amackey/6615429 to your computer and use it in GitHub Desktop.
Subversion post-commit hook that talks to JIRA
#!/usr/bin/perl
use warnings;
use strict;
use SVN::Hooks;
use SVN::Hooks::CheckJira;
use WWW::Mechanize;
CHECK_JIRA_CONFIG("http://www.hostname.com:8080", "username", "password", qr/(.*)/ms);
CHECK_JIRA(qr/./ => { require => 0,
post_action => sub {
my ($jira, $svnlook, @keys) = @_;
my $msg = $svnlook->log_msg();
if ($msg =~ m/^#comment/ms) {
my $comment = sprintf(<<EOM, $svnlook->repo(), $svnlook->rev(), $msg);
[auto-msg] new %s revision %s :
%s
check the Subversion tab for more details!
EOM
for my $key (@keys) {
$jira->addComment($key, $comment);
}
}
# attempt to fire the SVN indexer
my $mech = WWW::Mechanize->new();
$mech->get("http://www.hostname.com:8080/secure/UpdateDatabaseServer!startIndexer.jspa");
$mech->submit_form(fields => { os_username => "admin_username",
os_password => "admin_password",
});
},
},
);
run_hook($0, @ARGV);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment