Prompt
GitLab CI/CD build test deploy
Latest observation
Oct 19, 2026
OpenAI APIWeb search: off
Here’s a simple GitLab CI/CD build-test-deploy pipeline you can use as a starting point.
1) Basic pipeline stages
Typical flow:
- build – compile/package the app
- test – run unit/integration tests
- deploy – deploy to staging/production
2) Example .gitlab-ci.yml
stages:
- build
- test
- deploy
variables:
APP_NAME: my-app
build_job:
stage: build
image: node:20
script:
- npm ci
- npm run build
artifacts:
paths:
- dist/
expire_in: 1 week
test_job:
stage: test
image: node:20
script:
- npm ci
- npm test
deploy_job:
stage: deploy
image: alpine:latest
script:
- echo "Deploying ${APP_NAME}..."
- ./deploy.sh
only:
- main
3) What it does
- build_job: installs dependencies and builds the app
- test_job: runs tests
- deploy_job: deploys only when code is pushed to
main
4) Common improvements
Use environment-specific deploys
deploy_staging:
stage: deploy
script:
- ./deploy.sh staging
only:
- develop
deploy_production:
stage: deploy
script:
- ./deploy.sh production
only:
- main
Add manual approval for production
deploy_production:
stage: deploy
script:
- ./deploy.sh production
when: manual
only:
- main
Cache dependencies
cache:
paths:
- node_modules/
5) Best practices
- Keep build, test, and deploy separate
- Run tests before deployment
- Store secrets in GitLab CI/CD Variables
- Use artifacts to pass build outputs between jobs
- Restrict production deploys to protected branches/tags
If you want, I can generate a full GitLab CI/CD pipeline for your specific stack, like:
- Node.js
- Python
- Java/Maven
- Docker
- Kubernetes
- AWS / Azure / GCP