Processing the Webhook in FlexDeploy
Before using the browser extension to send webhooks, you’ll need to complete some setup in FlexDeploy for confirming the webhook sender and defining what actions to trigger. Make sure to read our Incoming Webhooks pages first for a more detailed overview.
Webhook Provider
There will need to be at least one webhook provider for the browser extension. To provide a stronger level of security, a provider match script is used to verify a webhook is actually coming from your FlexDeploy browser extension before running any actions. The following match script example validates the webhook sender based on a token query parameter, the origin header, and the from URL attribute in the payload. You could also split the extension into multiple providers depending on the from URL, or skip checking this attribute.
Extension Provider Match Script
def tokenQueryParam = QUERY_PARAMS.get('token');
def originHeader = HTTP_HEADERS.get('origin');
def fromURL = PAYLOAD.get('fromURL');
if (tokenQueryParam && originHeader && fromURL)
{
// TOKEN is an encrypted provider property
// CHROME_EXTENSION_ID is a provider property. The origin header is sent in the form chrome-extension://<id>
if (TOKEN.equals(tokenQueryParam) && CHROME_EXTENSION_ID.equals(originHeader) && fromURL.startsWith('http://apexhostname'))
{
LOG.fine('FlexDeploy Extension is a match');
return true;
}
}
return false;
Webhook Functions
From here, there should be at least one webhook function configured to trigger actions in FlexDeploy based on the payload content. There are a variety of actions which can be performed, including building a project, creating a package, managing a release, committing to source control, and more. Check out the Webhook Function Samples and the FlexDeploy Methods pages for more ideas.
Payload Format
The following is a reference of the payload format which is sent from the browser extension. Action name and source URL are sent with each webhook and properties will vary based on the properties in your webhook action.
{
"actionName": "Name of action sent",
"fromURL": "URL of the active window the sender was on when the webhook was sent",
"properties": [
{
"Property A Name": "Property A Value"
},
{
"Property B Name": "Property B Value"
},
{
"List Property C Name": ["Property C Value1", "Property C Value2", "Property C Value3"]
}
]
}
- style