GitLab CICD
Overview
GitLab CI/CD helps automate the software development process by integrating and deploying code efficiently. It streamlines tasks such as building, testing, linting, containerizing, and deploying, ensuring secure and consistent delivery pipelines.
GitLab Runners
GitLab Runners execute CI/CD jobs in your pipelines. They can be hosted by GitLab or managed by you.
-
SaaS Runners
- Hosted by GitLab and shared across projects.
- Simple to use, with no setup required.
-
Self-managed Runners
- Hosted on your own infrastructure.
- Offers more control and customization options.
How Runners Deploy Code
Runners automate the process of turning committed code into deployed applications.
- Code is committed to the repository.
- GitLab CI/CD pipeline is triggered.
- Runner clones the repository to its local environment.
- Runner reads and executes the
.gitlab-ci.yml
script. - Runners build the application.
- Tests and linting are performed.
- Security checks and containerization are applied.
- Application is deployed to the target environment.
GitLab CI/CD Configuration
The GitLab CI/CD pipeline is defined in a .gitlab-ci.yml file, which specifies jobs like building, testing, and deploying. These jobs are executed by GitLab Runners.
stages:
- build
- test
- deploy
build_job:
stage: build
script:
- echo "Building the application"
test_job:
stage: test
script:
- echo "Running tests"
deploy_job:
stage: deploy
script:
- echo "Deploying the application"
Create a GitLab Account
Creating a GitLab account allows you to access repositories, run CI/CD pipelines, and manage projects.
- Visit the GitLab website.
- Click on the "Sign up" or "Get free trial" button.
- Enter your name, email address, username, and password.
- You can also opt to sign in using Google account or Github account.
- Complete the setup by adding additional details (optional).
- Start using GitLab for your projects.
Limits
GitLab's free trial offers a limited set of features and quotas.
- Log in to your GitLab account.
- Click your profile photo > Edit Profile > Usage Quotas
- Review the available usage limits for pipelines, storage, and other features.
Each trial account has access of up to 400 compute units every month, which are used for running CI/CD jobs and other compute tasks. Make sure to monitor your usage to avoid hitting the monthly limit.
For more information, please see Compute minutes administration.
Groups
In GitLab, groups are used to organize and manage multiple projects. A group allows teams to collaborate on related projects, share permissions, and centralize management. Groups help simplify user access and security by applying settings across all projects within the group.
To create a new group, go to Groups > New Group > Create Group
Specify the details then click Create Group.
Projects
Projects in GitLab are similar to repositories and serve as containers for your code, issues, CI/CD pipelines, and other resources. Each project can be used to manage a single application or multiple components of a larger system.
- Create a project to store and organize your code.
- Set up project settings, including access control and permissions.
- Manage issues, merge requests, and CI/CD pipelines within the project.
- Collaborate with team members and track project progress.
To create a project, select the group > New project > Create blank project
Add a name to your project. You can choose to set it to private and you can also let it initialize a README file. Click Create project.
You should now see the README file of your new repository.