Once the connection to your AWS CodeCommit is made from Gearset and CI job webhook set-up is configured correctly by following this document, we would now look at few more steps for the webhook to trigger a CI job when a new pull request (PR) is raised against the branch a CI job is tracking and not just when the PR is merged/pushed.
Before you begin, you need your Repository ARN from your existing configuration.
This can be found under CodeCommit > Repositories > gearset_demo > Settings page. Copy and keep it handy.
Firstly, on your AWS console, search for EventBridge
Open Amazon EventBridge service by clicking on it.
Create new EventBridge rule.
Enter event rule name and select ‘Rule with an event pattern’ option, click Next.
In step 2 of ‘Build event pattern’ select Event source as ‘AWS events or EventBridge partner events’
Under ‘Creation method’ section on the same page,
Choose Method = Use pattern form
Under ‘Event Pattern’, set
Event source = AWS services
AWS service = CodeCommit
Event type = CodeCommit Pull Request State Change
Select Specific resource(s) by ARN
Copy and paste your Repository ARN that you had noted in the beginning and click Next.
On the Select target(s) page,
Select Target Type as ‘AWS service’
Under Select a target, choose ‘SNS topic’
Choose the name of the Topic you had created as part of initial webhook setup.
In the following example, the Topic name selected is ‘Webhook’
Click ‘Next’ again
On the final step Review the setup and Save the configuration. Now you can see new Event rule which you just created under Events > Rules
Just to ensure that you have CodeCommit trigger setup right, check if your configuration is on the similar lines as below
This should complete the whole setup process for trigger to work upon creation of pull request in AWS CodeCommit. Test this configuration by creating new pull request to the branch that CI job is associated with.
Still need some help? Contact our team and we'll be happy to assist. See how.
Let me know if this helped with your reaction below!