
A development team utilizes AWS CodeCommit, AWS CodePipeline, and AWS CodeBuild for their application development and deployment workflow. They manage code changes through pull requests, which are reviewed and merged by the team before triggering the pipeline to build and test the application. As the volume of pull requests has grown, the pipeline often encounters blockages due to test failures. To streamline this process and prevent pipeline blockages, the team seeks a solution to automatically execute unit and integration tests on each pull request prior to its merger. What AWS services and configurations should be employed to fulfill this requirement?
A
Create a CodeBuild project to run the unit and integration tests. Create a CodeCommit approval rule template. Configure the template to require the successful invocation of the CodeBuild project. Attach the approval rule to the project's CodeCommit repository.
B
Create an Amazon EventBridge rule to match pullRequestCreated events from CodeCommit. Create a CodeBuild project to run the unit and integration tests. Configure the CodeBuild project as a target of the EventBridge rule that includes a custom event payload with the CodeCommit repository and branch information from the event.
C
Create an Amazon EventBridge rule to match pullRequestCreated events from CodeCommit. Modify the existing CodePipeline pipeline to not run the deploy steps if the build is started from a pull request. Configure the EventBridge rule to run the pipeline with a custom payload that contains the CodeCommit repository and branch information from the event.
D
Create a CodeBuild project to run the unit and integration tests. Create a CodeCommit notification rule that matches when a pull request is created or updated. Configure the notification rule to invoke the CodeBuild project.
Explanation:
Option B is the correct answer. It describes a solution that creates an Amazon EventBridge rule to detect pullRequestCreated events from CodeCommit and then triggers a CodeBuild project to run unit and integration tests. This solution also includes passing information about the CodeCommit repository and branch from the event to the CodeBuild project as a custom payload. This ensures that tests are run on each pull request before it is merged, thereby preventing the pipeline from being blocked by failing tests.
Ultimate access to all questions.