3.4.6 Commit Code to Invoke Build/Test/Deploy
Commit Code to Invoke Build, Test, and Deployment
CodePipeline Flow
Git Push → Source Stage → Build Stage → Test Stage → Deploy Stage
Pipeline Triggers
| Source | Trigger |
|---|
| GitHub | Webhook via CodeStar Connection |
| S3 | CloudTrail event on PutObject |
| ECR | Image push event |
CodeBuild — buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
python: 3.12
pre_build:
commands:
- pip install -r requirements.txt
- pytest tests/
build:
commands:
- sam build
- sam package --s3-bucket $BUCKET --output-template packaged.yaml
artifacts:
files:
- packaged.yaml
Pipeline Concepts
| Concept | Mô tả |
|---|
| Stage | Logical group (Source, Build, Deploy) |
| Action | Task within stage |
| Artifact | Files passed between stages (S3) |
| Transition | Can be disabled between stages |
Exam Tip: Git push → webhook → CodePipeline. buildspec.yml phases: install → pre_build → build → post_build. Artifacts stored in S3.