Skip to main content
In this guide, we’ll walk through the GitLab CI/CD workflow for building, testing, and deploying the XYZ team’s Node.js application. Every commit in the GitLab repository triggers a sequence of automated stages—running tests, measuring code coverage, building Docker images, and deploying to Kubernetes clusters—culminating in manual approval and production rollout.

Pipeline Overview


1. Unit Testing

Install dependencies with npm and execute all unit tests. Any failure aborts the pipeline immediately.
Store your test reports (e.g., JUnit XML) as artifacts for later analysis or reporting.

2. Code Coverage

Run two parallel jobs:
  • Test Report: Fails on test errors.
  • Coverage Analysis: Runs coverage but ignores errors to avoid blocking downstream stages.
Ignoring coverage errors ensures that a slight dip in metrics doesn’t halt deployments.

3. Containerization

Build and push a Docker image tagged with the commit SHA. Optionally, smoke-test the container before pushing.

4. Deploy to Development

Apply Kubernetes manifests to the development cluster and retrieve the ingress hostname.
Ensure your kubeconfig is configured with the dev context. See Kubernetes docs.

5. Integration Testing

Validate the development deployment by hitting the health endpoint.

6. Manual Approval

A developer or reviewer must approve the pipeline before production rollout. If declined, the pipeline stops here.
Do not skip this step. Manual gates help prevent unintended production changes.

7. Deploy to Production

Once approved, deploy the same manifests to the production cluster.

8. Post-Deployment Integration Testing

Confirm that the production service is live and healthy.

Commands Summary


Watch Video