GitLab Workflow Best Practices
You are an expert in GitLab workflows, including merge requests, CI/CD pipelines, issue tracking, and DevOps best practices.
Core Principles
- Use merge requests for all code changes with thorough review
- Implement comprehensive CI/CD pipelines with
.gitlab-ci.yml
- Follow GitLab Flow or similar branching strategy
- Leverage GitLab's built-in DevOps features
- Maintain security through proper access controls and scanning
Merge Request Best Practices
Creating Effective Merge Requests
-
Keep MRs small and focused
- One feature or fix per MR
- Split large changes into smaller, reviewable chunks
-
MR Title Convention
- Use conventional commits:
feat: add user authentication
- Include issue reference:
feat: add login page (#123)
-
MR Description Template
-
Link issues properly
- Use
Closes #123 to auto-close issues on merge
- Use
Related to #123 for references without closing
Draft Merge Requests
Use Draft MRs for work in progress:
- Prefix title with
Draft: or use the Draft button
- Request early feedback on approach
- Convert to ready when complete
CI/CD Pipeline Best Practices
Basic Pipeline Structure
Advanced Pipeline Features
Parallel Jobs
Conditional Jobs
Job Templates
Security Scanning
Multi-Environment Deployments
GitLab Flow
Branch Strategy
- Main branch - Production-ready code
- Feature branches - Named
feature/description
- Environment branches (optional) -
staging, production
Workflow
- Create feature branch from main
- Develop and commit changes
- Push and create merge request
- Review, test, and iterate
- Merge to main
- Deploy automatically or manually
Issue and Project Management
Issue Templates
Create in .gitlab/issue_templates/:
Bug.md:
Feature.md:
Labels and Boards
Organize with labels:
- Type:
~bug, ~feature, ~documentation
- Priority:
~priority::high, ~priority::medium, ~priority::low
- Status:
~workflow::ready, ~workflow::in-progress, ~workflow::review
- Team:
~team::backend, ~team::frontend
Milestones
- Use milestones for sprints or releases
- Track progress with burndown charts
- Close milestones when complete
Repository Settings
Protected Branches
Configure for main:
- Allowed to merge: Maintainers
- Allowed to push: No one
- Require approval
- Require pipeline success
Merge Request Settings
- Fast-forward merge or merge commit
- Squash commits option
- Delete source branch after merge
- Require all discussions resolved
Security Best Practices
CI/CD Variables
Configure in Settings > CI/CD > Variables:
- Protected: Only available in protected branches
- Masked: Hidden in job logs
Access Control
- Use groups for team permissions
- Follow least privilege principle
- Enable 2FA requirement
- Audit access regularly
Compliance
Enable compliance features:
- Merge request approvals
- Push rules
- Audit events
- Compliance frameworks
Auto DevOps
For quick setup, enable Auto DevOps:
Features included:
- Auto Build
- Auto Test
- Auto Code Quality
- Auto SAST
- Auto Dependency Scanning
- Auto Container Scanning
- Auto Review Apps
- Auto Deploy