DVA-C02 Question 271
Select 2You are working on a CI/CD pipeline using AWS CodePipeline and AWS CodeBuild. Your team uses a GitHub repository with multiple branches: 'main', 'develop', and feature branches such as 'feature/new-ui'. You want to ensure that the pipeline automatically triggers for changes pushed to the 'develop' branch and runs additional integration tests whenever a pull request is raised to merge changes into the 'main' branch. Which combination of actions should you implement to achieve this?
- A
Configure a webhook in GitHub to trigger the pipeline for changes in the 'develop' branch.
- B
Set up a CodeBuild project that runs integration tests and configure it to trigger on pull request events for the 'main' branch.
- C
Modify the pipeline's source stage to use the 'main' branch instead of the 'develop' branch.
- D
Add a rule in CodePipeline to trigger the pipeline on all branches.
- E
Create a second pipeline specifically for running integration tests on the 'main' branch.
Show answer and explanation
Correct answers: A, B
Explanation
The correct approach involves configuring GitHub webhooks to automatically trigger the pipeline for changes pushed to the 'develop' branch and setting up a CodeBuild project for integration tests that runs during pull requests to the 'main' branch. This ensures the CI/CD workflow is efficient and meets the specific requirements without adding unnecessary complexity.
- A. Correct.
Correct: Configuring a webhook in GitHub ensures that changes in the 'develop' branch automatically trigger the pipeline. This aligns with the requirement to trigger builds when changes are pushed to 'develop'.
- B. Correct.
Correct: Setting up a CodeBuild project to handle integration tests and triggering it on pull request events for the 'main' branch meets the requirement for additional testing during pull requests.
- C. Incorrect.
Incorrect: Modifying the pipeline's source to use the 'main' branch would prevent it from detecting changes in the 'develop' branch, which does not meet the requirement.
- D. Incorrect.
Incorrect: Triggering the pipeline on all branches is overly broad and does not align with the specific requirements for triggering on 'develop' and pull requests to 'main'.
- E. Incorrect.
Incorrect: Creating a second pipeline is unnecessary and adds complexity. The same pipeline can handle both tasks with proper configuration.