createWebhook method
For an existing CodeBuild build project that has its source code stored in a GitHub or Bitbucket repository, enables CodeBuild to start rebuilding the source code every time a code change is pushed to the repository.
May throw InvalidInputException.
May throw OAuthProviderException.
May throw ResourceAlreadyExistsException.
May throw ResourceNotFoundException.
Parameter projectName :
The name of the CodeBuild project.
Parameter 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.
Parameter buildType :
Specifies the type of build this webhook will trigger.
Parameter filterGroups :
An array of arrays of WebhookFilter objects used to determine
which webhooks are triggered. At least one WebhookFilter in
the array must specify EVENT as its type.
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.
Parameter manualCreation :
If manualCreation is true, CodeBuild doesn't create a webhook in GitHub
and instead returns payloadUrl and secret values
for the webhook. The payloadUrl and secret
values in the output can be used to manually create a webhook within
GitHub.
Parameter pullRequestBuildPolicy :
A PullRequestBuildPolicy object that defines comment-based approval
requirements for triggering builds on pull requests. This policy helps
control when automated builds are executed based on contributor
permissions and approval workflows.
Parameter scopeConfiguration :
The scope configuration for global or organization webhooks.
Implementation
Future<CreateWebhookOutput> createWebhook({
required String projectName,
String? branchFilter,
WebhookBuildType? buildType,
List<List<WebhookFilter>>? filterGroups,
bool? manualCreation,
PullRequestBuildPolicy? pullRequestBuildPolicy,
ScopeConfiguration? scopeConfiguration,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'CodeBuild_20161006.CreateWebhook'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'projectName': projectName,
if (branchFilter != null) 'branchFilter': branchFilter,
if (buildType != null) 'buildType': buildType.value,
if (filterGroups != null) 'filterGroups': filterGroups,
if (manualCreation != null) 'manualCreation': manualCreation,
if (pullRequestBuildPolicy != null)
'pullRequestBuildPolicy': pullRequestBuildPolicy,
if (scopeConfiguration != null)
'scopeConfiguration': scopeConfiguration,
},
);
return CreateWebhookOutput.fromJson(jsonResponse.body);
}