Jenkins::NotificationListener - is a TCP server that listens to messages from Jenkins Notification plugin.
use Jenkins::NotificationListener; Jenkins::NotificationListener->new( host => $host , port => $port , on_notify => sub { my $payload = shift; # Jenkins::Notification; print $payload->name , " #" , $payload->build->number, " : " , $payload->status , " : " , $payload->phase , " : " , $payload->url , "\n"; })->start;
Jenkins::NotificationListener is a simple TCP server listens to messages from Jenkins' Notification plugin,
Jenkins::NotificationListener uses AnyEvent::Socket to create tcp server object, so it's a non-blocking implementation.
This tcp server reads JSON format notification from Jenkins Notification plugin, and creates payload object Jenkins::Notification. the payload object is built with Net::Jenkins::Job, Net::Jenkins::Job::Build objects from the information that is provided from notification json.
By using Jenkins::NotificationListener, you can simple use the payload object to interact with Jenkins server.
To test your Jenkins notification plugin, you can also use jenkins-notification-listener.pl script.
$ jenkins-notification-listener.pl
use Jenkins::NotificationListener; # export parse_jenkins_notification function my $notification = parse_jenkins_notification($json); $notification; # Jenkins::Notification object $notification->job; $notification->build;
$ cpan Jenkins::Notification $ cpanm Jenkins::Notification
Yo-An Lin <cornelius.howl {at} gmail.com>
Net::Jenkins
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Jenkins::NotificationListener, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Jenkins::NotificationListener
CPAN shell
perl -MCPAN -e shell install Jenkins::NotificationListener
For more information on module installation, please visit the detailed CPAN module installation guide.