Practical Tips for Using GitLab

· 2 min read

Our company has been using GitLab for code management, and in practice, we’ve accumulated various tips and techniques that I’d like to document here.

GitLab - Rich APIs

Leveraging these APIs can accomplish many tasks, such as using API + pipeline to create automated Merge Requests.

For example, we use Jenkins to regularly run changelog submissions to the repository, which also relies on GitLab API.

API Documentation - make sure to check your specific installation version

Pipeline

GitLab provides CI+CD capabilities. While Jenkins itself is also a CD tool, our team’s current practice is to use GitLab only for CI (running unit tests), and use hooks to trigger Jenkins for CD deployments across different environments.

Note that CI/CD configuration files themselves have directive support, so you can share configuration code blocks across multiple projects.

Templates

For MRs, Issues, etc., we can create templates. For example, in my team, we use a rotation system for Merge Owners, but remembering who it is today can be tedious. Therefore, we created templates so that each time, when reviewing an MR, checking the MR Guide will show who it is today.

Commit Syntax Sugar

Enabling pipelines is indeed great for ensuring merge code safety, but what if sometimes I want to merge directly without going through the pipeline? OK, GitLab provides syntax sugar [skip ci], but generally avoid using it.

Besides this, there are also commands like Fixes #45, etc.