GitLab Platform
Introduction to GitLab
GitLab is a complete DevOps platform that enables professionals to perform all the tasks in a project—from project planning and source code management to monitoring and security.
Key Features:
- Source Code Management
- CI/CD Pipelines
- Container Registry
- Issue Tracking
- Wiki & Documentation
- Security Scanning
- Monitoring & Metrics
- Value Stream Analytics
Project Setup
# Clone repository
git clone git@gitlab.com:namespace/project.git
# Configure GitLab CLI
glab auth login
# Create new project
glab repo create project-name
# Configure GitLab CI
touch .gitlab-ci.yml
# Push changes
git add .gitlab-ci.yml
git commit -m "Add GitLab CI configuration"
git push origin main
CI/CD Pipeline
Pipeline Configuration
# .gitlab-ci.yml
image: node:latest
stages:
- test
- build
- deploy
variables:
NODE_ENV: production
cache:
paths:
- node_modules/
test:
stage: test
script:
- npm install
- npm test
coverage: '/Coverage: \d+.\d+%/'
build:
stage: build
script:
- npm install
- npm run build
artifacts:
paths:
- dist/
deploy:
stage: deploy
script:
- echo "Deploying application..."
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- dpl --provider=heroku --app=$HEROKU_APP --api-key=$HEROKU_API_KEY
only:
- main
environment:
name: production
url: https://$HEROKU_APP.herokuapp.com
Pipeline Rules
workflow:
rules:
- if: $CI_COMMIT_TAG
when: always
- if: $CI_COMMIT_BRANCH == "main"
when: always
- if: $CI_MERGE_REQUEST_ID
when: always
- when: never
.only-main:
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: always
.only-tags:
rules:
- if: $CI_COMMIT_TAG
when: always
.only-mr:
rules:
- if: $CI_MERGE_REQUEST_ID
when: always
Repository Management
Merge Request Settings
# .gitlab/merge_request_templates/Default.md
## What does this MR do?
- [ ] Feature implementation
- [ ] Bug fix
- [ ] Documentation update
## Related issues
Closes #123
## Definition of Done
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] Merge conflicts resolved
- [ ] Code review completed
- [ ] CI pipeline passes
## Screenshots
If applicable, add screenshots
## Dependencies
List any dependencies that need to be addressed
Protected Branches
Branch Protection Rules:
- Require approval from code owners
- Prevent force push
- Require status checks to pass
- Include administrators
- Require signed commits
- Require linear history
- Allow merge only if pipeline succeeds
- Delete source branch on merge
Issues & Epics
Issue Template
# .gitlab/issue_templates/Feature.md
### Problem to Solve
Describe the problem that needs to be solved
### Proposed Solution
Describe your proposed solution
### User Story
As a [user type]
I want to [perform action]
So that [achieve goal]
### Acceptance Criteria
- [ ] Criterion 1
- [ ] Criterion 2
- [ ] Criterion 3
### Technical Requirements
- Implementation details
- API specifications
- Database changes
### Security Considerations
- Authentication requirements
- Authorization rules
- Data protection needs
### Testing Strategy
- Unit tests
- Integration tests
- E2E tests
Epic Management:
- Group related issues
- Track progress
- Set milestones
- Assign labels
- Add time estimates
- Monitor burndown charts
- Link dependencies
- Generate roadmaps
Security & Compliance
Security Scanning
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/Container-Scanning.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
sast:
variables:
SAST_EXCLUDED_PATHS: "spec, test, tests, tmp"
dependency_scanning:
variables:
DS_EXCLUDED_PATHS: "spec, test, tests, tmp"
container_scanning:
variables:
CS_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
secret_detection:
variables:
SECRET_DETECTION_HISTORIC_SCAN: "true"
Security Features:
- SAST (Static Application Security Testing)
- DAST (Dynamic Application Security Testing)
- Container scanning
- Dependency scanning
- Secret detection
- License compliance
- Security dashboards
- Vulnerability reports
Deployment & Monitoring
Environment Configuration
.environment-config:
environment:
name: production
url: https://example.com
deployment_tier: production
action: start
resource_group: production
deploy:
extends: .environment-config
script:
- kubectl apply -f k8s/
rules:
- if: $CI_COMMIT_BRANCH == "main"
needs:
- build
- test
monitoring:
script:
- curl ${CI_ENVIRONMENT_URL}/_health
needs:
- deploy
Monitoring Features:
- Metrics dashboard
- Error tracking
- Logging
- Performance monitoring
- Tracing
- Alerts
- Incident management
- Service level indicators