← worklog

2019-01-15

CI/CD pipeline for Java services on AWS

JavaSpring BootAWSDockerJenkins

Pipeline stages

  1. Maven build + unit tests
  2. Docker image build (multi-stage — builder + runtime image)
  3. Push to ECR with semantic version tag and latest
  4. ECS blue/green deployment using CodeDeploy
  5. Smoke tests against the new task set
  6. Shift traffic 100% → old task set teardown

Blue/green on ECS

ECS + CodeDeploy handles the routing shift. The key is the appspec.yaml and the lifecycle hook for smoke tests before traffic cutover. If the hook fails, CodeDeploy rolls back automatically.

Build time

Initial naive pipeline: 18 minutes. After parallelizing test stages and caching Maven dependencies in an EFS-mounted directory shared across Jenkins agents: 6 minutes.

What I'd change

Maven caching on EFS works but it's fragile — cache corruption causes mysterious build failures. Docker layer caching with a proper registry cache (BuildKit + --cache-from) is cleaner. Replaced it a year later when the team migrated to GitLab CI.