Manage GitHub Webhook
Since QuickBuild 15.0, you can manage GitHub Webhook settings via REST API.
GitHub Webhook Plugin Settings
The permissions for managing GitHub Webhook Plugin Settings should be admin.
List GitHub Webhook Plugin Settings
List the settings of GitHub Webhook plugin which you can set up for your organization level webhooks.
GET /rest/webhook/github/plugin_settings
By default, the media type of return result is XML, you can add request header Accept to change the media type, for example, add below header to get JSON result:
Accept: application/json
Update GitHub Webhook Plugin Settings
Update the settings of GitHub Webhook Plugin:
POST /rest/webhook/github/plugin_settings
The request data here should be in JSON format, below is an example:
{
"mappings": [
{
"repo": "myorg/repo1",
"configuration": "9"
},
{
"repo": "myorg/repo2",
"configuration": "root/my/configuration/path"
}
],
"secret": "mysecretlife"
}
mappingsare a list of pair of GitHub repository and QuickBuild configuration (id or path).secretis the webhook secret which you should have defined in GitHub.
Delete GitHub Webhook Plugin Settings
DELETE /rest/webhook/github/plugin_settings
GitHub Webhook Configuration Settings
If you want to manage GitHub webhook for each configuration, you can use the configuration settings.
The permissions for GitHub Webhook Configuration settings should be granted EDIT_SETTINGS of the configuration
List GitHub Webhook Configuration Settings
GET /rest/webhook/github/configuration_settings/{configurationId}
replace configurationId to the actual id of the configuration you want.
By default, the media type of return result is XML, you can add request header Accept to change the media type, for example, add below header to get JSON result:
Accept: application/json
Update GitHub Webhook Configuration Settings
POST /rest/webhook/github/configuration_settings/{configurationId}
replace configurationId to the actual id of the configuration you want.
{
"secret": "mysecretlife",
"username": "admin",
"condition": "target == \"android\"",
"variables": [
{
"name": "url",
"value": "http://localhost"
}
]
}
The fields above is same as what should be defined in UI.
secretis the webhook secret which you should have defined in GitHub.usernameis the QuickBuild user (username here) to trigger the build who should at least haveRUN_BUILDpermission for this configuration.conditionis an optional field which are some Groovy scripts to tell QuickBuild on which condition the build should be triggered.variablesis a list of build variables. Each variable should containnameand itsvalue, all should be string type.
Delete GitHub Webhook Configuration Settings
DELETE /rest/webhook/github/configuration_settings/{configurationId}
replace configurationId to the actual id of the configuration you want.