GitLab CI/CD - Hands-On Lab: Working with CI/CD Components
Objectives
A component is a reusable CI/CD configuration. Many of GitLab’s provided CI/CD features are provided as components. In this lab, you will learn how to add a CI/CD component to your GitLab project.
Task A. Finding the SAST Component
GitLab stores CI/CD components inside of the CI/CD catalog. To view the catalog:
-
In the left sidebar, select Search or go to.
-
In the resulting dialog, select Explore.
-
In the left sidebar, select CI/CD Catalog. This will show you a list of all of the CI/CD catalog items available in your GitLab instance. For this lab, you will be adding SAST to your project. Select the SAST component.
When you select a CI/CD component, you will see a Readme
, which describes how to use the component, as well as configuration options for the component. For the SAST component, you will see that it can be included using the following code:
include:
- component: ilt.gitlabtraining.cloud/components/sast/sast@<VERSION>
Let’s add this to our CI/CD file.
Task B. Adding the SAST component
-
Navigate to your CI/CD project by clicking on the Tanuki logo in the top left corner of the page, then click on your project name.
-
From the project, select your
.gitlab-ci.yml
file. -
Select Edit > Edit in Pipeline Editor.
-
At the top of your file, below the image, add the SAST import at version main.
include:
- component: ilt.gitlabtraining.cloud/components/sast/sast@main
The top of the .gitlab-ci.yml
file should look like this:
workflow:
rules:
- if: $CI_COMMIT_TAG
when: never
- when: always
default:
image: golang
include:
- component: ilt.gitlabtraining.cloud/components/sast/sast@main
-
Select Commit changes.
-
After committing your changes, navigate to the pipeline created for your commit. You will now see a new job named semgrep-sast. This job is the security scan imported using the
include
keyword.
Lab Guide Complete
You have completed this lab exercise. You can view the other lab guides for this course.
Suggestions?
If you wish to make a change to the Hands-On Guide for GitLab CI/CD, please submit your changes via Merge Request!
6f6d0996
)