Pipeline Design for Microservices

Independent Pipelines

The main promise of microservices is independent deployment: the payments team can release on Tuesday without waiting for the catalogue team. That only works if every service has its own pipeline that builds, tests and deploys just that service.

git push (order-service/**)
      |
      v
 +---------+   +-------------------+   +-------------+   +-----------+   +--------------+
 |  Build  |-->| Test: unit,       |-->| Docker image|-->| Deploy to |-->| Deploy to    |
 | mvn     |   | integration       |   | push :sha   |   | staging + |   | production   |
 | verify  |   | (Testcontainers), |   | + scan      |   | smoke test|   | (approval,   |
 +---------+   | contract tests    |   +-------------+   +-----------+   |  canary)     |
               +-------------------+                                     +--------------+
   CI = Continuous Integration: every change is built and tested
   CD = Continuous Delivery (one click to prod) / Deployment (automatic to prod)

Monorepo or Polyrepo?

Monorepo (all services in one Git repo)Polyrepo (one repo per service)
PipelinesOne workflow per service, triggered by paths: filtersOne workflow per repo
Shared codeEasy: a shared module (but beware coupling)Published as versioned libraries
Cross-service changeOne pull requestSeveral PRs, released in order
Access controlCoarsePer team
Used byGoogle, Uber, many startupsAmazon, Netflix, many enterprises

Note: Both work. What matters is that a change to order-service builds and deploys only order-service.

What to Test Where

Test typeChecksToolRuns in
UnitBusiness logic in one classJUnit 5, MockitoEvery push
IntegrationService + real database/Kafka@SpringBootTest + TestcontainersEvery push
ContractMy API still matches what consumers expectSpring Cloud Contract, PactEvery push, both sides
Smoke / end-to-endKey flows work in a real environmentREST Assured, Postman/NewmanAfter deploy to staging

Tip: Avoid one giant end-to-end suite that needs all 15 services: it is slow and flaky, and it couples releases again. Contract tests give most of the safety at a fraction of the cost.