Blog Engineering Define input parameters to includable CI/CD configuration files
2023-05-08
2 min read

Define input parameters to includable CI/CD configuration files

This is the first milestone of the long-term roadmap of the CI/CD Components Catalog roadmap.

migration-data.jpg

In GitLab 15.11, we introduced an exciting new feature that allows users to define input parameters for includable configuration files. With the ability to use input parameters in CI templates, you can replace any keyword in the template with a parameter, including stage, script, or job name. For example, you can add a prefix to all of the jobs to better isolate them from the pipeline into which you are including the configuration.

These input parameters can be declared as mandatory or optional for each configuration file, reducing the need for global variables and making your CI/CD templates more robust and isolated. The input parameters are scoped to the included configuration only, which means they have no impact on the rest of the pipeline. This allows you to declare and enforce constraints, for example by enforcing mandatory inputs for templates.

This development is the first milestone of the long-term roadmap of the CI/CD Components Catalog, a new feature that will allow users to search and reuse single-purpose CI/CD configuration units with specific parameters for their use case. If you want to learn more about this exciting new development, you can read our blog post about our CI templates feature.

In this technical blog post, we will provide step-by-step instructions on how to define CI/CD templates with input parameters and how to use them when including templates.

Step 1: Create a template YAML document

The first step is to create a template YAML document that describes what input arguments can be used with the template. The second part of the template is the definition of the jobs that may include references to values using the interpolation format $[[ inputs.input-name ]]. You should use three dash lines between the two parts.

Here is an example of a deploy-template.yml:

spec:
  inputs:
    website:
    environment:
      default: test

We want to hear from you

Enjoyed reading this blog post or have questions or feedback? Share your thoughts by creating a new topic in the GitLab community forum. Share your feedback

Ready to get started?

See what your team could do with a unified DevSecOps Platform.

Get free trial

New to GitLab and not sure where to start?

Get started guide

Learn about what GitLab can do for your team

Talk to an expert