⏱️ Estimated read: 3 min
|
|
1. Repositories & SSH/HTTPS Authentication
git clone git@gitlab.com:group/project.git # Clone via SSH
git clone https://gitlab.com/group/project.git # Clone via HTTPS
ssh-keygen -t ed25519 -C "email@example.com" # Generate SSH key
ssh -T git@gitlab.com # Test SSH connection
# PAT (Personal Access Token) clone
git clone https://<username>:<token>@gitlab.com/group/project.git
2. Project & Group Hierarchy
| Level | Purpose | Contains |
|---|
| Group | Organization | Subgroups, projects |
| Subgroup | Team | Subgroups, projects |
| Project | Repository | Code, issues, MRs, CI/CD |
Create group: Menu → Groups → New group
Create project: Menu → Projects → New project
Max nesting: 20 levels
3. Merge Requests (MRs)
glab mr create --fill --reviewer username # Create MR via CLI
glab mr list # List MRs
glab mr checkout 42 # Checkout MR branch
glab mr merge 42 --squash --remove-source-branch # Merge MR via CLI
# Resolve conflicts locally
git fetch origin
git merge origin/main
# Edit conflicted files, then:
git add <file> && git commit && git push
4. Protected Branches
Settings → Repository → Protected branches
Branch: main
Allowed to merge: Maintainers
Allowed to push: Maintainers
Allowed to force push: Disabled
| Role | Can Push to main? (Default) |
|---|
| Guest | No |
| Reporter | No |
| Developer | No (protected) |
| Maintainer | Yes |
| Owner | Yes |
5. .gitlab-ci.yml Basic Structure
stages:
- build
- test
- deploy
build-job:
stage: build
script:
- npm ci
- npm run build
artifacts:
paths:
- dist/
test-job:
stage: test
needs: [build-job]
script:
- npm test
6. CI/CD Pipeline Keywords
| Keyword | Purpose |
|---|
stages | Defines execution order |
script | Commands to run |
image | Container environment |
needs | Bypass stage barrier (DAG) |
rules | Conditional execution |
artifacts | Pass files between jobs |
cache | Reuse dependencies |
environment | Deployment target |
7. rules and Conditional Execution
deploy:
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: manual
- if: $CI_COMMIT_TAG
- when: never
when Value | Meaning |
|---|
on_success | Run if previous jobs pass |
on_failure | Run only on failure |
always | Always run |
never | Never run |
manual | Require manual trigger |
delayed | Delay start |
8. CI/CD Variables
Settings → CI/CD → Variables → Add variable
Key: DEPLOY_TOKEN
Value: <secret>
Masked: Yes
Protected: Yes
Environment scope: production
| Variable | Purpose |
|---|
CI_COMMIT_SHA | Commit hash |
CI_COMMIT_BRANCH | Branch name |
CI_PIPELINE_ID | Pipeline ID |
CI_REGISTRY_IMAGE | Container registry path |
CI_JOB_TOKEN | Short-lived job token |
9. Runners
sudo gitlab-runner register --token "glrt-xxxx" --executor "docker"
sudo systemctl restart gitlab-runner
| Executor | Use Case |
|---|
docker | Container isolation |
shell | Direct host execution |
kubernetes | Pod-based scaling |
10. Container Registry (GHCR Equivalent)
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
script:
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
11. DevSecOps Scanners
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Jobs/Dependency-Scanning.gitlab-ci.yml
| Scanner | Template |
|---|
| SAST | Security/SAST.gitlab-ci.yml |
| Secret Detection | Security/Secret-Detection.gitlab-ci.yml |
| Dependency Scanning | Jobs/Dependency-Scanning.gitlab-ci.yml |
12. Environments and Deployments
deploy-staging:
environment:
name: staging
url: https://staging.example.com
script: ./deploy.sh
deploy-prod:
environment:
name: production
when: manual
allow_failure: false
script: ./deploy.sh
Settings → CI/CD → Protected environments
Environment: production
Allowed to deploy: Maintainers
Required approvals: 1
13. Kubernetes Agent
helm upgrade --install my-agent gitlab/gitlab-agent \
--namespace gitlab-agent \
--set config.token=<token> \
--set config.kasAddress=wss://kas.gitlab.com
# .gitlab/agents/my-agent/config.yaml
gitops:
manifest_projects:
- id: my-group/manifests
14. Access Control
| Role | Key Permissions |
|---|
| Guest | View issues, comment |
| Reporter | View code, clone |
| Developer | Push, create MRs |
| Maintainer | Manage settings, protect branches |
| Owner | Delete project, transfer |
| Visibility | Visible To |
|---|
| Private | Members only |
| Internal | Authenticated users |
| Public | Anyone |
15. Webhooks & API
curl --header "PRIVATE-TOKEN: <token>" \
"https://gitlab.example.com/api/v4/projects"
| Header | Token Type |
|---|
PRIVATE-TOKEN | Personal access token |
JOB-TOKEN | CI/CD job token |
Authorization: Bearer | OAuth |
16. Analytics
| Metric | Definition |
|---|
| Lead Time | Issue creation to closure |
| Cycle Time | First commit to issue closure |
| DORA: Deployment Frequency | Deployments per day |
| DORA: Change Failure Rate | Failed deployments % |
17. Migration
| Source | Tool |
|---|
| GitHub | Create new → Import project → GitHub |
| Bitbucket Cloud | Create new → Import project → Bitbucket Cloud |
| Git History only | Repository by URL |
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!