#GitLab

GitLab is an all-in-one DevOps platform with built-in CI/CD.


#Key Features

FeatureDescription
RepositoriesCode hosting
Merge RequestsCode review
CI/CDBuilt-in pipelines
Container RegistryDocker images
KubernetesK8s integration
Self-HostedOn-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

FeatureGitLabGitHub
CI/CDBuilt-inGitHub Actions
Self-hostedFreeEnterprise only
RegistryBuilt-inPackages
KubernetesNativeActions

[!TIP] Pro Tip: GitLab's built-in CI/CD is powerful and doesn't require marketplace actions!