Explore Gitlab CI components
Explore how we can set up an example CI component project and demonstrate the usage.
Intro
A CI/CD component is a reusable single pipeline configuration unit. Use components to create a small part of a larger pipeline, or even to compose a complete pipeline configuration. A component project is a GitLab project with a repository that hosts one or more components.
Purpose
What problems does it solve?
- Provide a description, sane defaults, and validation for the vars.
- No more telling users to create vars in pipelines
- Ease of use since it is a drop-in to their CI config with
include: componentkeyword - Separation of concerns for software and infrastructure/CI code testing.
- Efficient (time to dev and test). We can test the infrastructure code and the CI separately from the application code.
- Avoid long wait times for the application code to compile and deploy when we want to test the infra code/CICD
- Efficient (time to dev and test). We can test the infrastructure code and the CI separately from the application code.
- Standardized code.
- Reduces code repetition
- Eliminates scrolling 100's of lines, which leads to toil and missed changes
- Speeds up dev.
- Create more dynamic jobs.
- Enforces good release practices - semantic versioning etc.
- Easily discoverable when published to a catalog
- Central place for components. Easy to distribute.
Usage
Let's see how we can add a component to our project.
- A drop in with
include: componentkeyword
include:
- component: $CI_SERVER_FQDN/my-org/security-components/secret-detection@1.0.0
inputs:
stage: build
-
$CI_SERVER_FQDNis a predefined variable for the fully qualified domain name (FQDN) matching the GitLab host. You can only reference components in the same GitLab instance as your project. -
my-org/security-componentsis the full path of the project containing the component. -
secret-detectionis the component name that is defined as either a single filetemplates/secret-detection.ymlor as a directorytemplates/secret-detection/containing atemplate.yml. -
1.0.0is the version of the component.
Roadmap
The following tasks are identified to implement CICD components for rc/hpc-factory
Please refer to this issue for a roadmap. hpc-factory#301
Edited by Eesaan Atluri