AWS CodeCommit is no longer available to new customers. Existing customers of
AWS CodeCommit can continue to use the service as normal.
Learn more"
Test triggers for an AWS CodeCommit repository
You can test the triggers that have been created for a CodeCommit repository. Testing involves running the trigger with sample data from your repository, including the most recent commit ID. If no commit history exists for the repository, sample values consisting of zeroes are generated instead. Testing triggers helps you confirm you have correctly configured access between CodeCommit and the target of the trigger, whether that is an AWS Lambda function or an Amazon Simple Notification Service notification.
Test a trigger for a repository (console)
Open the CodeCommit console at https://console.aws.amazon.com/codesuite/codecommit/home
. -
In Repositories, choose the repository where you want to test a trigger for repository events.
-
In the navigation pane for the repository, choose Settings, and then choose Triggers.
-
Choose the trigger you want to test, and then choose Test trigger. You should see a success or failure message. If successful, you should also see a corresponding action response from the Lambda function or the Amazon SNS topic.
Test a trigger for a repository (AWS CLI)
At a terminal (Linux, macOS, or Unix) or command prompt (Windows), run the get-repository-triggers command to create a JSON file with the structure of all of the triggers configured for your repository. For example, to create a JSON file named
TestTrigger.jsonwith the structure of all of the triggers configured for a repository named MyDemoRepo:aws codecommit get-repository-triggers --repository-name MyDemoRepo >TestTrigger.jsonThis command creates a file named
TestTriggers.jsonin the directory where you ran the command.-
Edit the JSON file in a plain-text editor and make the changes to the trigger statement. Replace the
configurationIdpair with arepositoryNamepair. Save the file.For example, if you want to test a trigger named
MyFirstTriggerin the repository namedMyDemoReposo that it applies to all branches, replace theconfigurationIdwithrepositoryNameand then save a file that looks similar to the following asTestTrigger.json:{ "repositoryName": "MyDemoRepo", "triggers": [ { "destinationArn": "arn:aws:sns:us-east-2:111122223333:MyCodeCommitTopic", "branches": ["main", "preprod"], "name": "MyFirstTrigger", "customData": "", "events": [ "all" ] } ] } At the terminal or command line, run the test-repository-triggers command. This updates all triggers for the repository, including the changes you made to the
MyFirstTriggertrigger:aws codecommit test-repository-triggers --cli-input-json file://TestTrigger.jsonThis command returns a response similar to the following:
{ "successfulExecutions": [ "MyFirstTrigger" ], "failedExecutions": [] }