Amazon CodeCommit is no longer available to new customers. Existing customers of
Amazon CodeCommit can continue to use the service as normal.
Learn more"
Test triggers for an Amazon 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 Amazon Lambda function or an Amazon Simple Notification Service notification.
Test a trigger for a repository (console)
Open the CodeCommit console at https://console.www.amazonaws.cn/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 (Amazon CLI)
At a terminal (Linux, OS X, 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.json
with the structure of all of the triggers configured for a repository named MyDemoRepo:aws codecommit get-repository-triggers --repository-name MyDemoRepo >TestTrigger.json
This command creates a file named
TestTriggers.json
in 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
configurationId
pair with arepositoryName
pair. Save the file.For example, if you want to test a trigger named
MyFirstTrigger
in the repository namedMyDemoRepo
so that it applies to all branches, replace theconfigurationId
withrepositoryName
and 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
MyFirstTrigger
trigger:aws codecommit test-repository-triggers --cli-input-json file://
TestTrigger.json
This command returns a response similar to the following:
{ "successfulExecutions": [ "MyFirstTrigger" ], "failedExecutions": [] }