Class WebhookNotificationProcessor
java.lang.Object
org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
org.craftercms.deployer.impl.processors.AbstractPostDeploymentProcessor
org.craftercms.deployer.impl.processors.notification.NotificationProcessor<NotificationProcessor.NotificationMessage>
org.craftercms.deployer.impl.processors.notification.WebhookNotificationProcessor
- All Implemented Interfaces:
DeploymentProcessor
,InitializableByConfigBean
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
public class WebhookNotificationProcessor
extends NotificationProcessor<NotificationProcessor.NotificationMessage>
NotificationProcessor
implementation that sends a webhook notification with the result of the deployment.
The deployment is available to the template as an object with the key "deployment", and serialized as JSON with the key "deployentJson".
A WebhookNotificationProcessor
instance can be configured with the following YAML properties (in addition to the common ones from NotificationProcessor
):
- url: The URL to send the webhook notification to.
- method: The HTTP method to use. Default is
post
. - contentType: The content type of the request body. Default is
application/json
-
Nested Class Summary
Nested classes/interfaces inherited from class org.craftercms.deployer.impl.processors.notification.NotificationProcessor
NotificationProcessor.NotificationMessage, NotificationProcessor.StatusCondition
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.fasterxml.jackson.databind.ObjectMapper
Fields inherited from class org.craftercms.deployer.impl.processors.notification.NotificationProcessor
DATETIME_PATTERN_CONFIG_KEY, dateTimeFormatter, DEFAULT_ENCODING, DEPLOYMENT_MODEL_KEY, END_MODEL_KEY, failedProcessorsPattern, LAST_DATETIME_FILE_SUFFIX_CONFIG_KEY, MUTE_PERIOD_MINUTES_CONFIG_KEY, mutePeriodMinutes, PROCESSOR_MATCH_PATTERNS_CONFIG_KEY, SERVER_NAME_CONFIG_KEY, SERVER_NAME_MODEL_KEY, serverName, START_MODEL_KEY, STATUS_CONDITION_CONFIG_KEY, STATUS_MODEL_KEY, statusCondition, TARGET_ID_MODEL_KEY, TEMPLATE_NAME_CONFIG_KEY, templateName
Fields inherited from class org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
alwaysRun, env, excludeFiles, includeFiles, JUMPING_TO_PARAM_NAME, jumpTo, label, name, siteName, targetId
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoCreateMessage
(Deployment deployment) Creates the notification message to send.void
doInit
(org.apache.commons.configuration2.Configuration config) Allows extending classes perform any custom initializationprotected void
Sends the notification message.void
setDefaultContentType
(String defaultContentType) void
setDefaultMethod
(String defaultMethod) void
setObjectMapper
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Methods inherited from class org.craftercms.deployer.impl.processors.notification.NotificationProcessor
createMessage, doDestroy, doPostProcess, populateModel, processTemplate, setDefaultDateTimePattern, setDefaultLastDateFilenameSuffix, setDefaultStatusCondition, setDefaultTemplateName, setFreeMarkerConfig, setProcessorStateStore, setTemplateEncoding, setTemplatePrefix, setTemplateSuffix
Methods inherited from class org.craftercms.deployer.impl.processors.AbstractPostDeploymentProcessor
doExecute, isPostDeployment, shouldExecute
Methods inherited from class org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
destroy, execute, getDeploymentParam, getFilteredChangeSet, init, isJumpToActive, setBeanName, setEnv, setSiteName, setTargetId, shouldIncludeFile, startJumpTo, supportsMode
-
Field Details
-
objectMapper
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Details
-
WebhookNotificationProcessor
public WebhookNotificationProcessor()
-
-
Method Details
-
doInit
public void doInit(org.apache.commons.configuration2.Configuration config) throws org.craftercms.commons.config.ConfigurationException, DeployerException Description copied from class:AbstractDeploymentProcessor
Allows extending classes perform any custom initialization- Overrides:
doInit
in classNotificationProcessor<NotificationProcessor.NotificationMessage>
- Parameters:
config
- the bean's configuration- Throws:
org.craftercms.commons.config.ConfigurationException
- if there's configuration related exceptionDeployerException
- if there's a general exception on init
-
doCreateMessage
protected NotificationProcessor<NotificationProcessor.NotificationMessage>.NotificationMessage doCreateMessage(Deployment deployment) Description copied from class:NotificationProcessor
Creates the notification message to send.- Specified by:
doCreateMessage
in classNotificationProcessor<NotificationProcessor.NotificationMessage>
- Parameters:
deployment
- the deployment object- Returns:
- the notification message
-
doNotify
Description copied from class:NotificationProcessor
Sends the notification message.- Specified by:
doNotify
in classNotificationProcessor<NotificationProcessor.NotificationMessage>
- Parameters:
message
- the notification message- Throws:
DeployerException
- if an error occurs while sending the notification
-
setDefaultMethod
-
setDefaultContentType
-
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-