CreateWebhook
For an existing AWS CodeBuild build project that has its source code stored in a GitHub or Bitbucket repository, enables AWS CodeBuild to start rebuilding the source code every time a code change is pushed to the repository.
Important
If you enable webhooks for an AWS CodeBuild project, and the project is used as a build step in CodePipeline, then two identical builds are created for each commit. One build is triggered through webhooks, and one through CodePipeline. Because billing is on a per-build basis, you are billed for both builds. Therefore, if you are using CodePipeline, we recommend that you disable webhooks in AWS CodeBuild. In the AWS CodeBuild console, clear the Webhook box. For more information, see step 5 in Change a Build Project's Settings.
Request Syntax
{
"branchFilter": "string
",
"buildType": "string
",
"filterGroups": [
[
{
"excludeMatchedPattern": boolean
,
"pattern": "string
",
"type": "string
"
}
]
],
"manualCreation": boolean
,
"projectName": "string
",
"scopeConfiguration": {
"domain": "string
",
"name": "string
",
"scope": "string
"
}
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
Note
In the following list, the required parameters are described first.
- projectName
-
The name of the AWS CodeBuild project.
Type: String
Length Constraints: Minimum length of 2. Maximum length of 150.
Pattern:
[A-Za-z0-9][A-Za-z0-9\-_]{1,149}
Required: Yes
- branchFilter
-
A regular expression used to determine which repository branches are built when a webhook is triggered. If the name of a branch matches the regular expression, then it is built. If
branchFilter
is empty, then all branches are built.Note
It is recommended that you use
filterGroups
instead ofbranchFilter
.Type: String
Required: No
- buildType
-
Specifies the type of build this webhook will trigger.
Type: String
Valid Values:
BUILD | BUILD_BATCH
Required: No
- filterGroups
-
An array of arrays of
WebhookFilter
objects used to determine which webhooks are triggered. At least oneWebhookFilter
in the array must specifyEVENT
as itstype
.For a build to be triggered, at least one filter group in the
filterGroups
array must pass. For a filter group to pass, each of its filters must pass.Type: Array of arrays of WebhookFilter objects
Required: No
- manualCreation
-
If manualCreation is true, CodeBuild doesn't create a webhook in GitHub and instead returns
payloadUrl
andsecret
values for the webhook. ThepayloadUrl
andsecret
values in the output can be used to manually create a webhook within GitHub.Note
manualCreation
is only available for GitHub webhooks.Type: Boolean
Required: No
- scopeConfiguration
-
The scope configuration for global or organization webhooks.
Note
Global or organization webhooks are only available for GitHub and Github Enterprise webhooks.
Type: ScopeConfiguration object
Required: No
Response Syntax
{
"webhook": {
"branchFilter": "string",
"buildType": "string",
"filterGroups": [
[
{
"excludeMatchedPattern": boolean,
"pattern": "string",
"type": "string"
}
]
],
"lastModifiedSecret": number,
"manualCreation": boolean,
"payloadUrl": "string",
"scopeConfiguration": {
"domain": "string",
"name": "string",
"scope": "string"
},
"secret": "string",
"url": "string"
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
Errors
For information about the errors that are common to all actions, see Common Errors.
- InvalidInputException
-
The input value that was provided is not valid.
HTTP Status Code: 400
- OAuthProviderException
-
There was a problem with the underlying OAuth provider.
HTTP Status Code: 400
- ResourceAlreadyExistsException
-
The specified AWS resource cannot be created, because an AWS resource with the same settings already exists.
HTTP Status Code: 400
- ResourceNotFoundException
-
The specified AWS resource cannot be found.
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: