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.
See also: AWS API Documentation
create-webhook
--project-name <value>
[--branch-filter <value>]
[--filter-groups <value>]
[--build-type <value>]
[--manual-creation | --no-manual-creation]
[--scope-configuration <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]
--project-name
(string)
The name of the CodeBuild project.
--branch-filter
(string)
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 usefilterGroups
instead ofbranchFilter
.
--filter-groups
(list)
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.(list)
(structure)
A filter used to determine which webhooks trigger a build.
type -> (string)
The type of webhook filter. There are nine webhook filter types:
EVENT
,ACTOR_ACCOUNT_ID
,HEAD_REF
,BASE_REF
,FILE_PATH
,COMMIT_MESSAGE
,TAG_NAME
,RELEASE_NAME
, andWORKFLOW_NAME
.
EVENT
- A webhook event triggers a build when the provided
pattern
matches one of nine event types:PUSH
,PULL_REQUEST_CREATED
,PULL_REQUEST_UPDATED
,PULL_REQUEST_CLOSED
,PULL_REQUEST_REOPENED
,PULL_REQUEST_MERGED
,RELEASED
,PRERELEASED
, andWORKFLOW_JOB_QUEUED
. TheEVENT
patterns are specified as a comma-separated string. For example,PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED
filters all push, pull request created, and pull request updated events.Note
Types
PULL_REQUEST_REOPENED
andWORKFLOW_JOB_QUEUED
work with GitHub and GitHub Enterprise only. TypesRELEASED
andPRERELEASED
work with GitHub only.ACTOR_ACCOUNT_ID
- A webhook event triggers a build when a GitHub, GitHub Enterprise, or Bitbucket account ID matches the regular expression
pattern
.HEAD_REF
- A webhook event triggers a build when the head reference matches the regular expression
pattern
. For example,refs/heads/branch-name
andrefs/tags/tag-name
.Note
Works with GitHub and GitHub Enterprise push, GitHub and GitHub Enterprise pull request, Bitbucket push, and Bitbucket pull request events.
BASE_REF
- A webhook event triggers a build when the base reference matches the regular expression
pattern
. For example,refs/heads/branch-name
.Note
Works with pull request events only.
FILE_PATH
- A webhook triggers a build when the path of a changed file matches the regular expression
pattern
.Note
Works with GitHub and Bitbucket events push and pull requests events. Also works with GitHub Enterprise push events, but does not work with GitHub Enterprise pull request events.
COMMIT_MESSAGE
- A webhook triggers a build when the head commit message matches the regular expression
pattern
.Note
Works with GitHub and Bitbucket events push and pull requests events. Also works with GitHub Enterprise push events, but does not work with GitHub Enterprise pull request events.
TAG_NAME
- A webhook triggers a build when the tag name of the release matches the regular expression
pattern
.Note
Works with
RELEASED
andPRERELEASED
events only.RELEASE_NAME
- A webhook triggers a build when the release name matches the regular expression
pattern
.Note
Works with
RELEASED
andPRERELEASED
events only.REPOSITORY_NAME
- A webhook triggers a build when the repository name matches the regular expression pattern.
Note
Works with GitHub global or organization webhooks only.
WORKFLOW_NAME
- A webhook triggers a build when the workflow name matches the regular expression
pattern
.Note
Works with
WORKFLOW_JOB_QUEUED
events only.pattern -> (string)
For a
WebHookFilter
that usesEVENT
type, a comma-separated string that specifies one or more events. For example, the webhook filterPUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED
allows all push, pull request created, and pull request updated events to trigger a build.For a
WebHookFilter
that uses any of the other filter types, a regular expression pattern. For example, aWebHookFilter
that usesHEAD_REF
for itstype
and the pattern^refs/heads/
triggers a build when the head reference is a branch with a reference namerefs/heads/branch-name
.excludeMatchedPattern -> (boolean)
Used to indicate that thepattern
determines which webhook events do not trigger a build. If true, then a webhook event that does not match thepattern
triggers a build. If false, then a webhook event that matches thepattern
triggers a build.
Shorthand Syntax:
[{type=string,pattern=string,excludeMatchedPattern=boolean},{type=string,pattern=string,excludeMatchedPattern=boolean}] ...
JSON Syntax:
[
[
{
"type": "EVENT"|"BASE_REF"|"HEAD_REF"|"ACTOR_ACCOUNT_ID"|"FILE_PATH"|"COMMIT_MESSAGE"|"WORKFLOW_NAME"|"TAG_NAME"|"RELEASE_NAME"|"REPOSITORY_NAME",
"pattern": "string",
"excludeMatchedPattern": true|false
}
...
]
...
]
--build-type
(string)
Specifies the type of build this webhook will trigger.
Possible values:
BUILD
BUILD_BATCH
--manual-creation
| --no-manual-creation
(boolean)
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.
--scope-configuration
(structure)
The scope configuration for global or organization webhooks.
Note
Global or organization webhooks are only available for GitHub and Github Enterprise webhooks.name -> (string)
The name of either the group, enterprise, or organization that will send webhook events to CodeBuild, depending on the type of webhook.domain -> (string)
The domain of the GitHub Enterprise organization or the GitLab Self Managed group. Note that this parameter is only required if your project’s source type is GITHUB_ENTERPRISE or GITLAB_SELF_MANAGED.scope -> (string)
The type of scope for a GitHub or GitLab webhook.
Shorthand Syntax:
name=string,domain=string,scope=string
JSON Syntax:
{
"name": "string",
"domain": "string",
"scope": "GITHUB_ORGANIZATION"|"GITHUB_GLOBAL"|"GITLAB_GROUP"
}
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command. The generated JSON skeleton is not stable between versions of the AWS CLI and there are no backwards compatibility guarantees in the JSON skeleton generated.
--debug
(boolean)
Turn on debug logging.
--endpoint-url
(string)
Override command’s default URL with the given URL.
--no-verify-ssl
(boolean)
By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.
--no-paginate
(boolean)
Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.
--output
(string)
The formatting style for command output.
--query
(string)
A JMESPath query to use in filtering the response data.
--profile
(string)
Use a specific profile from your credential file.
--region
(string)
The region to use. Overrides config/env settings.
--version
(string)
Display the version of this tool.
--color
(string)
Turn on/off color output.
--no-sign-request
(boolean)
Do not sign requests. Credentials will not be loaded if this argument is provided.
--ca-bundle
(string)
The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.
--cli-read-timeout
(int)
The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.
--cli-connect-timeout
(int)
The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.
--cli-binary-format
(string)
The formatting style to be used for binary blobs. The default format is base64. The base64 format expects binary blobs to be provided as a base64 encoded string. The raw-in-base64-out format preserves compatibility with AWS CLI V1 behavior and binary values must be passed literally. When providing contents from a file that map to a binary blob fileb://
will always be treated as binary and use the file contents directly regardless of the cli-binary-format
setting. When using file://
the file contents will need to properly formatted for the configured cli-binary-format
.
--no-cli-pager
(boolean)
Disable cli pager for output.
--cli-auto-prompt
(boolean)
Automatically prompt for CLI input parameters.
--no-cli-auto-prompt
(boolean)
Disable automatically prompt for CLI input parameters.
To use the following examples, you must have the AWS CLI installed and configured. See the Getting started guide in the AWS CLI User Guide for more information.
Unless otherwise stated, all examples have unix-like quotation rules. These examples will need to be adapted to your terminal’s quoting rules. See Using quotation marks with strings in the AWS CLI User Guide .
To create webhook filters for an AWS CodeBuild project
The following create-webhook
example creates a webhook for a CodeBuild project named my-project
that has two filter groups. The first filter group specifies pull requests that are created, updated, or reopened on branches with Git reference names that match the regular expression ^refs/heads/master$
and head references that match ^refs/heads/myBranch$
. The second filter group specifies push requests on branches with Git reference names that do not match the regular expression ^refs/heads/myBranch$
.
aws codebuild create-webhook \
--project-name my-project \
--filter-groups "[[{\"type\":\"EVENT\",\"pattern\":\"PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED\"},{\"type\":\"HEAD_REF\",\"pattern\":\"^refs/heads/myBranch$\",\"excludeMatchedPattern\":true},{\"type\":\"BASE_REF\",\"pattern\":\"^refs/heads/master$\",\"excludeMatchedPattern\":true}],[{\"type\":\"EVENT\",\"pattern\":\"PUSH\"},{\"type\":\"HEAD_REF\",\"pattern\":\"^refs/heads/myBranch$\",\"excludeMatchedPattern\":true}]]"
Output:
{
"webhook": {
"payloadUrl": "https://codebuild.us-west-2.amazonaws.com/webhooks?t=eyJlbmNyeXB0ZWREYXRhIjoiVVl5MGtoeGRwSzZFRXl2Wnh4bld1Z0tKZ291TVpQNEtFamQ3RDlDYWpRaGIreVFrdm9EQktIVk1NeHJEWEpmUDUrVUNOMUIyRHJRc1VxcHJ6QlNDSnljPSIsIml2UGFyYW1ldGVyU3BlYyI6InN4Tm1SeUt5MUhaUVRWbGciLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&v=1",
"url": "https://api.github.com/repos/iversonic/codedeploy-sample/hooks/105190656",
"lastModifiedSecret": 1556311319.069,
"filterGroups": [
[
{
"type": "EVENT",
"pattern": "PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED",
"excludeMatchedPattern": false
},
{
"type": "HEAD_REF",
"pattern": "refs/heads/myBranch$",
"excludeMatchedPattern": true
},
{
"type": "BASE_REF",
"pattern": "refs/heads/master$",
"excludeMatchedPattern": true
}
],
[
{
"type": "EVENT",
"pattern": "PUSH",
"excludeMatchedPattern": false
},
{
"type": "HEAD_REF",
"pattern": "refs/heads/myBranch$",
"excludeMatchedPattern": true
}
]
]
}
}
For more information, see Filter GitHub Webhook Events (SDK) in the AWS CodeBuild User Guide.
webhook -> (structure)
Information about a webhook that connects repository events to a build project in CodeBuild.
url -> (string)
The URL to the webhook.payloadUrl -> (string)
The CodeBuild endpoint where webhook events are sent.secret -> (string)
The secret token of the associated repository.
Note
A Bitbucket webhook does not supportsecret
.branchFilter -> (string)
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 usefilterGroups
instead ofbranchFilter
.filterGroups -> (list)
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.(list)
(structure)
A filter used to determine which webhooks trigger a build.
type -> (string)
The type of webhook filter. There are nine webhook filter types:
EVENT
,ACTOR_ACCOUNT_ID
,HEAD_REF
,BASE_REF
,FILE_PATH
,COMMIT_MESSAGE
,TAG_NAME
,RELEASE_NAME
, andWORKFLOW_NAME
.
EVENT
- A webhook event triggers a build when the provided
pattern
matches one of nine event types:PUSH
,PULL_REQUEST_CREATED
,PULL_REQUEST_UPDATED
,PULL_REQUEST_CLOSED
,PULL_REQUEST_REOPENED
,PULL_REQUEST_MERGED
,RELEASED
,PRERELEASED
, andWORKFLOW_JOB_QUEUED
. TheEVENT
patterns are specified as a comma-separated string. For example,PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED
filters all push, pull request created, and pull request updated events.Note
Types
PULL_REQUEST_REOPENED
andWORKFLOW_JOB_QUEUED
work with GitHub and GitHub Enterprise only. TypesRELEASED
andPRERELEASED
work with GitHub only.ACTOR_ACCOUNT_ID
- A webhook event triggers a build when a GitHub, GitHub Enterprise, or Bitbucket account ID matches the regular expression
pattern
.HEAD_REF
- A webhook event triggers a build when the head reference matches the regular expression
pattern
. For example,refs/heads/branch-name
andrefs/tags/tag-name
.Note
Works with GitHub and GitHub Enterprise push, GitHub and GitHub Enterprise pull request, Bitbucket push, and Bitbucket pull request events.
BASE_REF
- A webhook event triggers a build when the base reference matches the regular expression
pattern
. For example,refs/heads/branch-name
.Note
Works with pull request events only.
FILE_PATH
- A webhook triggers a build when the path of a changed file matches the regular expression
pattern
.Note
Works with GitHub and Bitbucket events push and pull requests events. Also works with GitHub Enterprise push events, but does not work with GitHub Enterprise pull request events.
COMMIT_MESSAGE
- A webhook triggers a build when the head commit message matches the regular expression
pattern
.Note
Works with GitHub and Bitbucket events push and pull requests events. Also works with GitHub Enterprise push events, but does not work with GitHub Enterprise pull request events.
TAG_NAME
- A webhook triggers a build when the tag name of the release matches the regular expression
pattern
.Note
Works with
RELEASED
andPRERELEASED
events only.RELEASE_NAME
- A webhook triggers a build when the release name matches the regular expression
pattern
.Note
Works with
RELEASED
andPRERELEASED
events only.REPOSITORY_NAME
- A webhook triggers a build when the repository name matches the regular expression pattern.
Note
Works with GitHub global or organization webhooks only.
WORKFLOW_NAME
- A webhook triggers a build when the workflow name matches the regular expression
pattern
.Note
Works with
WORKFLOW_JOB_QUEUED
events only.pattern -> (string)
For a
WebHookFilter
that usesEVENT
type, a comma-separated string that specifies one or more events. For example, the webhook filterPUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED
allows all push, pull request created, and pull request updated events to trigger a build.For a
WebHookFilter
that uses any of the other filter types, a regular expression pattern. For example, aWebHookFilter
that usesHEAD_REF
for itstype
and the pattern^refs/heads/
triggers a build when the head reference is a branch with a reference namerefs/heads/branch-name
.excludeMatchedPattern -> (boolean)
Used to indicate that thepattern
determines which webhook events do not trigger a build. If true, then a webhook event that does not match thepattern
triggers a build. If false, then a webhook event that matches thepattern
triggers a build.buildType -> (string)
Specifies the type of build this webhook will trigger.manualCreation -> (boolean)
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.lastModifiedSecret -> (timestamp)
A timestamp that indicates the last time a repository’s secret token was modified.scopeConfiguration -> (structure)
The scope configuration for global or organization webhooks.
Note
Global or organization webhooks are only available for GitHub and Github Enterprise webhooks.name -> (string)
The name of either the group, enterprise, or organization that will send webhook events to CodeBuild, depending on the type of webhook.domain -> (string)
The domain of the GitHub Enterprise organization or the GitLab Self Managed group. Note that this parameter is only required if your project’s source type is GITHUB_ENTERPRISE or GITLAB_SELF_MANAGED.scope -> (string)
The type of scope for a GitHub or GitLab webhook.