Filter GitLab webhook events (console) - AWS CodeBuild

Filter GitLab webhook events (console)

Use the following instructions to use the AWS Management Console to filter webhook events. For more information about GitLab webhook events, see GitLab webhook events.

  1. Select Rebuild every time a code change is pushed to this repository when you create your project.

  2. From Event type, choose one or more events.

  3. To filter when an event triggers a build, under Start a build under these conditions, add one or more optional filters.

  4. To filter when an event is not triggered, under Don't start a build under these conditions, add one or more optional filters.

  5. Choose Add filter group to add another filter group.

For more information, see Create a build project (console) and WebhookFilter in the AWS CodeBuild API Reference.

In this example, a webhook filter group triggers a build for pull requests only:

A webhook filter group that triggers a build for pull requests only.

Using an example of two filter groups, a build is triggered when one or both evaluate to true:

  • The first filter group specifies pull requests that are created or updated on branches with Git reference names that match the regular expression ^refs/heads/main$ and head references that match ^refs/heads/branch1!.

  • The second filter group specifies push requests on branches with Git reference names that match the regular expression ^refs/heads/branch1$.

An example of two filter groups.

In this example, a webhook filter group triggers a build for all requests except tag events.

A webhook filter group that triggers a build for all requests except tag events.

In this example, a webhook filter group triggers a build only when files with names that match the regular expression ^buildspec.* change.

A webhook filter group that triggers a build only when files with names that match the regular expression specified.

In this example, a webhook filter group triggers a build only when files are changed in src or test folders.

A webhook filter group that triggers a build only when files are changed in specified folders.

In this example, a webhook filter group triggers a build only when a change is made by a GitLab user who does not have an account ID that matches the regular expression actor-account-id.

Note

For information about how to find your GitLab account ID, see https://api.github.com/users/user-name, where user-name is your GitLab user name.

A webhook filter group that triggers a build only when a change is made by a GitLab user who does not have an account ID.

In this example, a webhook filter group triggers a build for a push event when the head commit message matches the regular expression \[CodeBuild\].

A webhook filter group that triggers a build for a push event when the head commit message matches the regular expression.