QuerySurge has long emphasized team communication and information-sharing in its design. As part of that emphasis, webhook support was introduced in QuerySurge 10.0. With QuerySurge 10.3, we've added built-in support for GitHub Issue Creation via webhook.
This article describes the webhook setup for GitHub Issue creation.
GitHub provides a REST API, and in the following example, we set up a QuerySurge webhook that adds an issue to your GitHub repository.
- This is the URL template for GitHub REST API calls. Note that you'll need your specific GitHub account and repository name to complete the URL.
https://api.github.com/repos/<YourGitHubAccount>/<YourRepsitoryName>/issues
- GitHub uses basic authentication with a personal access token to authenticate API requests. Personal access tokens in GitHub can be generated by navigating to your account settings page and selecting “Developer settings”. Once in the Developer Settings page, click on the “Personal access tokens” option and select the Generate new token button to generate a new token.
You will then be taken to the "New Personal access token" screen where you will need to set the expiration date of the token as well as the selected scopes required. At a minimum, repo access is required when selecting the scope access for your personal access token.
After setting the expiration and selecting the scope, clicking on the “Generate token” button at the bottom of the screen will generate the new token. Note: Be sure to copy the token at this point as you will not be able to view it in GitHub again.
The newly generated token can now be applied to your webhook template in QuerySurge. We will utilize basic authentication setting where:
username=”token”
password="<yourPerosnalAccessToken>"
- The JSON payload in this example is simple to moderate in complexity. The JSON must follow GitHub API syntax rules (consult the GitHub API documentation). There are a few items of note here. You can insert QuerySurge values into the message, denoted by the ${...} syntax. Finally, this example is a "plain-vanilla" issue-creation example, meaning there are no required custom fields. If you have required custom fields, you'll need to find out how they are named in the JSON (again, consult the documentation) and configure them with QuerySurge values or hardcoded values as needed.
{
"title" : "Scenario ${scenarioName} has an outcome of: ${outcome}",
"body" : "Percent passing: ${passRate} %\nNumber of QueryPairs: ${numberOfQueryPairs}\n${queryPairsPassed} / ${numberOfQueryPairs} passed\n${queryPairsFailed} / ${numberOfQueryPairs} failed\n${queryPairsKilled}, ${queryPairWarnings}, ${queryPairErrors} killed, warning, errors\n\nRun Owner: ${owner}\nRun Start: ${startTime}\nRun End: ${endTime}\nDuration: ${duration}"
} - You have the option to add additional filters on an event. For example, you could limit the firing of the webhook to a specific owner (i.e. user), or in the "Scenario Ended" event, to whether the execution failed. The webhook Event Filters are identical to Email Notification Event Filters. For more information, see this.
- Your GitHub Issue looks like a standard issue (unless you have customized it):
Comments
0 comments
Article is closed for comments.