Skip to content

Add metadata to GitLab Managed CI/CD Templates [RUN ALL RSPEC] [RUN AS-IF-FOSS]

What does this MR do?

This MR adds metadata to GitLab Managed CI/CD Templates with partially supporting template_metadata keyword in .gitlab-ci.yml. This gives us a better maintainability such as:

  • What DevOps stage is involved in the template.
  • What feature category is involved in the template.
  • Which R&D group is responsible to maintain the template.
  • How to use the template.

These information will be visualized in the upcoming UX issue. This template_metadata keyword does not affect pipelines/jobs generation mechanizm at all. It's just a metadata container, so it's safe to be used.

Details of the template_metadata keyword

You must define the template metadata in a GitLab managed CI/CD template.

For fabricating the template information, we extended the capability of the CI/CD templates to have a structured metadata that can be populated on UI/API. Specifically, we've introduced template_metadata keyword to .gitlab-ci.yml that consists of the following attributes:

Attribute Description Required
name The name of the template. Yes
desc The description of the template. Yes
stages The GitLab DevOps Stages that the template is involved. Yes
categories The GitLab Feature Categories that the template is involved. Yes
maintainers The GitLab Groups which are responsible to maintain the template. Yes
usage How to use the template. See below for more details. Yes
inclusion_type How to use the template when usage is inclusion. See below for more details. Yes

The details of usage attributes:

Value Workflow management Description
copy-paste Decentralized The template is copy-pasted into a project workflow file and maintained/versioned in each repository. This is the tradional behavior of GitLab templates that provide a starter content to be a new instance, like Issue/MR templates.
inclusion Centralized The template is included into a project workflow file and maintained/versioned in the GitLab canonical repository. This is the unique concept in GitLab CI/CD that directly consumes a template.

The details of inclusion_type attributes:

Value Jobs defined? Global keyword exists? YAML anchors only? Description
shared-workflow Yes Yes/No No The end-to-end CI/CD workflow to be shared with the other projects.
workflow-extension No Yes No The extension of the workflow-level configs (i.e. global keywords) to be shared with the other projects.
composable-job No No Yes The YAML anchors to be included into the project workflow for composing a job with extends or !reference.
other Yes/No Yes/No Yes/No

NOTE: YAML anchors is a hidden configuration to be used with extends.

Related #334663 #335279

Important notes

template_metadata keyword will be allowed for users/organizations in the future (At this moment, we're experimenting this feature in GitLab managed templates only). For example, most of the attributes are optional for end-users, and we don't change this concept for GitLab managed templates. So that we're enforcing the GitLab specific practice in our daily testing pipelines (rspec).

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Shinya Maeda

Merge request reports