My company uses a self-hosted instance of GitLab. We’d like to use some of the official
GitLab CI/CD components, but we discovered that we cannot use them directly. To solve this,
I have created a mirror repository for each component and added them to our components’ repository. However, I’m having some trouble adding these to our CI/CD catalogue.
Using SAST as an example, here are the steps I’ve tried so far and the problem I’m facing.
Created the SAST Mirror
I created the mirror repository for the GitLab SAST component at https://gitlab.myorg.com.au/development/mirrors/gitlab-sast-component. This is
working fine and is regularly updated.
Created the Component Repository
Created a component project at https://gitlab.myorg.com.au/development/components
with some custom components that we’re already using. These are registered in the
CI/CD catalogue and are already being used in other projects.
Adding the Mirrored Component
In the development/components repository, I created a new templates/sast/template.yml file. This is what it looks like.
spec:
inputs:
enable_mr_pipelines:
default: false
type: boolean
excluded_analyzers:
default: ""
excluded_paths:
default: "spec, test, tests, tmp"
image_prefix:
default: "$CI_TEMPLATE_REGISTRY_HOST/security-products"
image_suffix:
default: ""
image_tag:
default: "6"
include_experimental:
default: false
type: boolean
run_advanced_sast:
default: false
type: boolean
run_advanced_sast_cpp:
default: false
type: boolean
run_kubesec_sast:
default: false
type: boolean
search_max_depth:
default: 4
type: number
stage:
default: test
advanced_sast_partial_scan:
description: "Configures the scan mode for Advanced SAST in merge requests. Set to 'differential' to scan only modified files and their dependencies, improving performance."
default: ""
---
include:
- component: $CI_SERVER_FQDN/development/mirrors/gitlab-sast-component
inputs:
stage: $[[ inputs.stage ]]
enable_mr_pipelines: $[[ inputs.enable_mr_pipelines ]]
excluded_analyzers: $[[ inputs.excluded_analyzers ]]
excluded_paths: $[[ inputs.excluded_paths ]]
image_prefix: $[[ inputs.image_prefix ]]
image_suffix: $[[ inputs.image_suffix ]]
image_tag: $[[ inputs.image_tag ]]
include_experimental: $[[ inputs.include_experimental ]]
run_advanced_sast: $[[ inputs.run_advanced_sast ]]
run_advanced_sast_cpp: $[[ inputs.run_advanced_sast_cpp ]]
run_kubesec_sast: $[[ inputs.run_kubesec_sast ]]
search_max_depth: $[[ inputs.search_max_depth ]]
advanced_sast_partial_scan: $[[ inputs.advanced_sast_partial_scan ]]
As I understand it, the idea is to just expose the mirrored component and available inputs.
Then, in .gitlab-ci.yml, I’ve added the following line
include:
# Other components...
- component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/sast@$CI_COMMIT_SHA
I pushed my branch and created an MR. However, the pipeline fails with this message.
Unable to create pipeline
- Component ‘gitlab.myorg.com.au/development/mirrors/gitlab-sast-component’ - the component path is not supported
I’m not sure what I’ve done wrong, or if what I’m trying to achieve is even possible. Any help would be greatly appreciated.
Thanks!
P.S. As this is a mirrored repositroy, I’m not sure how to use versioning with the component. Do I just use the tag?