#GitLab
GitLab is an all-in-one DevOps platform with built-in CI/CD.
#Key Features
| Feature | Description |
|---|---|
| Repositories | Code hosting |
| Merge Requests | Code review |
| CI/CD | Built-in pipelines |
| Container Registry | Docker images |
| Kubernetes | K8s integration |
| Self-Hosted | On-premise option |
#GitLab CI/CD Basics
yaml
1# .gitlab-ci.yml
2stages:
3 - build
4 - test
5 - deploy
6
7variables:
8 NODE_VERSION: "20"
9
10build:
11 stage: build
12 image: node:${NODE_VERSION}
13 script:
14 - npm ci
15 - npm run build
16 artifacts:
17 paths:
18 - dist/
19
20test:
21 stage: test
22 image: node:${NODE_VERSION}
23 script:
24 - npm ci
25 - npm test
26
27deploy:
28 stage: deploy
29 script:
30 - echo "Deploying to production..."
31 environment:
32 name: production
33 only:
34 - main#GitLab vs GitHub
| Feature | GitLab | GitHub |
|---|---|---|
| CI/CD | Built-in | GitHub Actions |
| Self-hosted | Free | Enterprise only |
| Registry | Built-in | Packages |
| Kubernetes | Native | Actions |
[!TIP] Pro Tip: GitLab's built-in CI/CD is powerful and doesn't require marketplace actions!