This document is a guide to setting up a webhook for CI jobs or Pipelines in Gearset, that deploys changes from an AWS CodeCommit repository when the source branch changes.
Prerequisites before setting up CodeCommit webhooks:
You have added a repository connection for AWS CodeCommit (see our guide on Integrating with AWS CodeCommit).
The AWS CodeCommit repository you are connecting to is not blank and that there is at least one branch (e.g. Main) to work with; otherwise, you will get an error when you select the
Source repository
field on the CIAdd new deployment job
page.
Each CI job/Pipeline environment requires the following setup on AWS CodeCommit:
1 Simple Notification Service (SNS) Topic
1 Subscription
1 Trigger
1 EventBridge rule
Creating a CI webhook for CodeCommit
To get started, from the Continuous integration page in Gearset, click
Add new deployment job
orAdd new team-shared deployment job
.Select
AWS CodeCommit
as theSource type
.Under
Deployment behavior
, selectwhen the source branch is updated
.
Configure the other options, click Save
, and you will see another dialog box with the webhook information in it. Next, save the Payload URL
and Shared secret
for use later on to create and configure your CodeCommit webhooks.
Creating a Pipelines webhook for CodeCommit
When configuring a Gearset Pipeline using AWS CodeCommit, you will also be asked to add a specific SNS Topic, Subscription & EventBridge Rule to allow all the Pipeline functionality to work as expected.
Note: A Pipeline webhook is required in addition to the CI job configuration, SNS Topics, and supporting elements written above.
Head to the Pipeline page, and click on the
Settings
cog, followed byAdd webhook...
This will bring up an informational modal explaining how to add in the SNS Topic, Subscription and EventBridge rule for your pipeline.
Note down your
Payload URL
andShared secret
, and proceed with the following steps to add your webhook.
Adding a Webhook
In the AWS Management Console, go to the
Amazon SNS
section and searchSimple Notification Service
.Create a
new topic
, then create anew subscription
for that topic.Choose a name for your topic, and set its type as
standard
.Set
Protocol
toHTTPS
.Set the
Endpoint
to thePayload URL
you have saved from Gearset’s webhook setup dialog earlier.The new subscription’s ID will be
Pending confirmation
.Click
Request confirmations
and hitrefresh
in the table. The subscription should then be assigned a proper subscription ID.In the AWS Management Console, go to
AWS CodeCommit
.For the repository you’re deploying, go to
Settings
, and then toTriggers
.Click
Create new trigger
.Under
Events
, selectPush to existing branch.
Do not select any branches under
Brach names
so the webhook works for all branches in your pipeline.Select the
SNS topic
you created earlier.Under
Custom data
, paste in theShared secret
from Gearset’s webhook setup dialog earlier.
You can click Test trigger
to confirm it can connect successfully. The next time you push to this branch, it will trigger the CI job in Gearset.
Setting up an EventBridge
rule
To set up an EventBridge
rule, please refer to our guide on EventBridge
configuration for the users using AWS CodeCommit.