com.twilio.jenkins
Class TwilioNotifier

java.lang.Object
  extended by hudson.tasks.BuildStepCompatibilityLayer
      extended by hudson.tasks.Publisher
          extended by hudson.tasks.Notifier
              extended by com.twilio.jenkins.TwilioNotifier
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Describable<hudson.tasks.Publisher>, hudson.tasks.BuildStep

public class TwilioNotifier
extends hudson.tasks.Notifier

A TwilioNotifier is a Notifier that uses the Rest API of communications service provider "http://www.twilio.com/ to send text messages and make calls with the build status of individual builds. This notifier was inspired in features and design by the Twitter Notifier plugin.

Author:
Christer Fahlgren (christer@twilio.com)

Nested Class Summary
static class TwilioNotifier.DescriptorImpl
           
 
Nested classes/interfaces inherited from class hudson.tasks.Publisher
hudson.tasks.Publisher.DescriptorExtensionListImpl
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
hudson.tasks.BuildStep.PublisherList
 
Field Summary
 
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
 
Constructor Summary
TwilioNotifier(String message, String toList, String onlyOnFailureOrRecovery, String includeUrl, String smsNotification, String callNotification, String userList, String sendToCulprits, String culpritMessage)
          Databound constructor matching the corresponding Jelly configuration items.
 
Method Summary
protected static String culpritStringFromList(List<Pair<String,String>> phoneToCulprit)
           
 hudson.util.FormValidation doCheckToList(String value)
          Validates the toList.
 Boolean getCallNotification()
          Getter for callNotification.
 String getCulpritMessage()
          Getter for the culprit message.
 TwilioNotifier.DescriptorImpl getDescriptor()
           
 Boolean getIncludeUrl()
          Returns the include url flag.
 String getMessage()
          Getter for the message.
 Boolean getOnlyOnFailureOrRecovery()
          Getter for onlyOnFailureOrRecovery flag.
 hudson.tasks.BuildStepMonitor getRequiredMonitorService()
           
 Boolean getSendToCulprits()
          Getter for sendToCulprits flag.
 Boolean getSmsNotification()
          Getter for smsNotification flag.
 String getToList()
          Getter for the toList.
 String getUserList()
          Getter for the message.
protected  boolean isFailureOrRecovery(hudson.model.AbstractBuild<?,?> build)
          Determine if this build represents a failure or recovery.
protected static Map<String,Pair<String,String>> parseUserList(String users)
           
 boolean perform(hudson.model.AbstractBuild<?,?> build, hudson.Launcher launcher, hudson.model.BuildListener listener)
           
protected  boolean shouldNotify(hudson.model.AbstractBuild<?,?> build)
          Determine if this build results should be tweeted.
protected static String substituteAttributes(String inputString, Map<String,String> substitutionMap)
           
 
Methods inherited from class hudson.tasks.Publisher
all, getProjectAction, needsToRunAfterFinalized, prebuild
 
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectActions, perform, prebuild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hudson.tasks.BuildStep
getProjectAction, getProjectActions, prebuild
 

Constructor Detail

TwilioNotifier

@DataBoundConstructor
public TwilioNotifier(String message,
                                           String toList,
                                           String onlyOnFailureOrRecovery,
                                           String includeUrl,
                                           String smsNotification,
                                           String callNotification,
                                           String userList,
                                           String sendToCulprits,
                                           String culpritMessage)
Databound constructor matching the corresponding Jelly configuration items.

Parameters:
message - the message to send
toList - the comma separated list of people to send to
onlyOnFailureOrRecovery - whether to send notification only on failure or recovery
includeUrl - whether to include a url to the build statu
smsNotification - whether to send text message
callNotification - whether to call
Method Detail

parseUserList

protected static Map<String,Pair<String,String>> parseUserList(String users)

substituteAttributes

protected static String substituteAttributes(String inputString,
                                             Map<String,String> substitutionMap)

getToList

public String getToList()
Getter for the toList.

Returns:
the toList

doCheckToList

public hudson.util.FormValidation doCheckToList(@QueryParameter
                                                String value)
Validates the toList.

Parameters:
value - the toList to validate
Returns:
FormValidation.ok if valid, FormValidation.error if not valid

getMessage

public String getMessage()
Getter for the message.

Returns:
the message

getCulpritMessage

public String getCulpritMessage()
Getter for the culprit message.

Returns:
the culprit message

getCallNotification

public Boolean getCallNotification()
Getter for callNotification.

Returns:
the callNotification flag

getSmsNotification

public Boolean getSmsNotification()
Getter for smsNotification flag.

Returns:
the smsNotification flag.

getSendToCulprits

public Boolean getSendToCulprits()
Getter for sendToCulprits flag.

Returns:
the sendToCulprits flag.

getIncludeUrl

public Boolean getIncludeUrl()
Returns the include url flag.

Returns:
the includeUrl flag

getOnlyOnFailureOrRecovery

public Boolean getOnlyOnFailureOrRecovery()
Getter for onlyOnFailureOrRecovery flag.

Returns:
the onlyOnFailureOrRecovery flag

getUserList

public String getUserList()
Getter for the message.

Returns:
the message

perform

public boolean perform(hudson.model.AbstractBuild<?,?> build,
                       hudson.Launcher launcher,
                       hudson.model.BuildListener listener)
Specified by:
perform in interface hudson.tasks.BuildStep
Overrides:
perform in class hudson.tasks.BuildStepCompatibilityLayer

culpritStringFromList

protected static String culpritStringFromList(List<Pair<String,String>> phoneToCulprit)

isFailureOrRecovery

protected boolean isFailureOrRecovery(hudson.model.AbstractBuild<?,?> build)
Determine if this build represents a failure or recovery. A build failure includes both failed and unstable builds. A recovery is defined as a successful build that follows a build that was not successful. Always returns false for aborted builds.

Parameters:
build - the Build object
Returns:
true if this build represents a recovery or failure

shouldNotify

protected boolean shouldNotify(hudson.model.AbstractBuild<?,?> build)
Determine if this build results should be tweeted. Uses the local settings if they are provided, otherwise the global settings.

Parameters:
build - the Build object
Returns:
true if we should tweet this build result

getDescriptor

public TwilioNotifier.DescriptorImpl getDescriptor()
Specified by:
getDescriptor in interface hudson.model.Describable<hudson.tasks.Publisher>
Overrides:
getDescriptor in class hudson.tasks.Notifier

getRequiredMonitorService

public hudson.tasks.BuildStepMonitor getRequiredMonitorService()


Copyright © 2004-2011. All Rights Reserved.