Environment

Environment Purpose
Local Developer laptop
Dev Shared team testing
SIT System Integration Test
UAT User Acceptance Testing
Staging Production-like
Prod Live traffic

Workflow

Checkout feature branch
      ↓
Developer writes code
      ↓
Push feature branch
      ↓
CI #1 (lint, unit test, security scan)
      ↓
Open Pull Request
      ↓
CI #2 (re-run tests, ensure merge safe)
      ↓
Code Review & Approval
      ↓
Merge to develop/main
      ↓
CD pipeline triggers
      ↓
Build Docker Image (if not built earlier)
      ↓
Push to Registry
      ↓
Deploy to Dev
      ↓
Promote to Staging
      ↓
UAT Testing
      ↓
Approval
      ↓
Deploy to Prod (5% Canary)
      ↓
Monitor
      ↓
Full rollout (100%)

Workflow:

  1. Work on dev feature branch

    git checkout -b feature/payment-timeout-fix
    
  2. Complete dev, commit and push to Remote (Feature Branch)

    git push origin feature/payment-timeout-fix
    
  3. Auto trigger and run CI Pipeline #1 (Feature Pipeline)

    1. Lint
    2. Unit tests
    3. Integration tests (sometimes mocked)
    4. Static code analysis (SonarQube)
    5. Security scan (Snyk / Trivy)

    ❌ No deployment

    ❌ No cluster access

    ❌ No Docker push (optional)

    stages:
      - build
      - test
      - docker
      - deploy
    
    build:
      stage: build
      script:
        - mvn clean package
    
    test:
      stage: test
      script:
        - mvn test
    
    docker-build:
      stage: docker
      script:
        - docker build -t $IMAGE_TAG .
        - docker push $IMAGE_TAG
    
  4. Pipeline pass, open Pull Request → target: develop or main

    1. If fail → you fix
  5. CI runs again on PR branch (since code may have changed OR other commits may have merged)

    deploy-dev:
      stage: deploy
      only:
        - develop
      script:
        - kubectl apply -f k8s/deployment-dev.yaml
    
  6. Code review happens

  7. PR Approved, branch merge to:

  8. Merge success auto trigger CD Pipeline

    1. Build Docker Image (ONLY ONCE)
      • Store it, later promote same artifact.
    2. Tag image: user-service:1.2.3
    3. Push to registry
    4. Deploy to Dev K8s cluster
    5. Run smoke tests
    deploy-prod:
      stage: deploy
      only:
        - main
      when: manual
      script:
        - kubectl apply -f k8s/deployment-prod.yaml
    
  9. QA start doing test.

  10. Promote to Staging / UAT