Webhooks
About Webhooks
Webhooks, (also called a web callback or HTTP push API) allows other applications to interface with XPRESSO using custom callbacks so it can push real-time information to those apps as it updates. Webhooks are a way for apps to communicate between them automatically.This differs from typical APIs where you need to poll for data frequently to get real-time information.
Some Webhooks allow applications to reply to XPRESSO, and can modify its behavior in some way. All Webhooks extended through XPRESSO are maintained by their owners.
Webhook Support and Output Requirements
XPRESSO supports the following types of Webhooks:
Pre-request run Webhooks: Allows Users to dynamically override (or append) the dynamic arguments for a Job Run, for example: environment and script arguments. The flow of the pre-request run hooks are as follows:
- User submits a Job Run via XPRESSO.
- The Request service sends the body of the Job Run to the Webhook.
- The Webhook provider can read/modify/append the environment and script arguments and return the body back to the Request service. The output must conform to the following conditions:
- The field “options” and “environment” must match in order for the Webhook to be functional; any other fields are ignored.
- The Webhook callback must respond within two seconds to avoid a timeout.
- The Request service saves the updates to the environment and script arguments.
- The Request service uses the updated environment and script arguments to submit the Job Run to the appropriate Execution Engine (Cloud or Jenkins).
Post-request run Webhooks: These are for notification purposes only. Once the Job Run is in one of the terminal states, the Post-request run Webhook is used to send the request body to the Webhook provider that contain the detailed information of the Job run, results, comparisons etc.
Requirements
Webhook can be registered in XPRESSO. See the parameter descriptions in the "To Register a New Webhooks" procedure below for the specific requirements. Also refer to this website for detailed information about XPRESSO Webhook requirements.
The following pre-configured Webhook are already part of the system to meet Cisco-internal test automation requirements:
CTC Webhook: CTC, (commonly referred to as Testwell CTC++, is a built-in pre-request run Webhook developed and maintained for Cisco-internal use only. The CTC Webhook automatically adds pyATS CTC job arguments to auto-enable the pyATS CTC Plugin. The pyATS CTC Plugin collects the coverage data and performs the required processing to post to Cerebro to provide Coverage Analytics. See this website for further information about CTC.
CRFT Webhook: This can be enabled at the Webhook page in the Group level settings in Xpresso. CRimson Function Tracking provides ALWAYS ON function level code instrumentation. A counter is kept for each function entry. At any point in time a user can issue a CLI to dump out all the counters on the box. This data can be extremely useful to debug issues. Detailed information is in this link.
Btrace Webhook: This can be enabled at the Webhook page in the Group level settings in Xpresso. The Btrace Trace-on-Failure infrastructure provides a mechanism to achieve a summary list of Application Contexts (MAC-address, IP, string) that have had an Error (ERR) or more severe failures and a detailed list of the btrace logs that precede the failure condition. Detailed information is in this link.
Job Request Webhooks: Allows Users to select from pre-register webhooks in Job Run Requests.
Registering New Webhooks
You can add your own Webhooks on demand to register your third-party applications to work with XPRESSO. Both Privilege Members and Group Admins can register new Webhooks in XPRESSO:
To Register a New Webhook:
From the Main Navigation Bar, choose Main Menu→ENVIRONMENT→Webhooks to open the Registered Request Webhooks page.
Click the Add Webhook button located on the right side of the page. The Add a New Request Webhook page appears.
Fill in all required parameter fields on the form.
Webhook Parameter Details
Name: Enter a unique identifier for the Webhook.
URL: Specify the website (URL) where the Webhook is located. The format must match – PROTOCOL://Server:port/path, where the supported protocols are HTTP or HTTPS, server is the hosting server of the Webhook, the port is the listening port (defaults to 80), and path is the URL path.
NOTE:
The specified URL must be reachable by XPRESSO and not located in a DMZ. XPRESSO does not validate the URL.
- Click the Save button to complete the action. Your new Webhook appears on the Registered Request Webhooks page. See the next procedure on how to apply your Webhook to a Job Request.
Applying Webhooks to Job Requests
After you register your Webhook in XPRESSO or if you use the pre-configured Webhook that ships with XPRESSO, you need to apply the applicable Webhook to each of your Job Requests.
To Apply a Webhook to a Job Request:
NOTE:
This procedure provides a précis of the applicable steps to apply a Webhook to a Job Request. Follow the Procedures outlined below for all required steps.
Create a New Job Request as outlined in this topic.
Configure the required Job Request wizard outlined in this topic.
Click the Profile Options step on the Job Request Wizard to locate the Webhook option.
Click on the pull-down menu to the right of the Enable Webhooks parameter to apply a Webhook to a Job Request (pre- or post can be specified). You can apply multiple Webhooks to a Job Request.
Finish executing your Job Request as outlined in this topic.
Post-registration Webhook Operations
You can perform the following post-registration management operations with Webhooks from the Registered Request Webhooks page (Main Navigation Bar→Main Menu→ENVIRONMENT→Webhooks).
Edit: Allows you to edit all fields on the Edit Webhook page with the exception of the Name field. To change the Name field, delete the Webhook and create a new one.
Delete: Allows you to delete a registered Webhook from the XPRESSO database.