Skip to content

Add map type for CI component input

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you can request access to GitLab Duo.

What does this MR do and why?

This merge request allows to pass a hash-map (for variables) as input to the component:

spec:
  inputs:
    variables:
      type: map # new type
      default:
        SOME_VARIABLE: "This is the example content of a variable"
        ANOTHER_VARIABLE: $CI_PROJECT_DIR/another/path

In my ci component i have a kinda LAMP stack (Linux, Apache/NGINX, MySQL/MariaDB/Postgres PHP) that runs as a service. A user might add redis or solr to the stack. These images are configurable through environment variables.

This will allow my component to have a services and variables added to run these additional services if need.

References

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Example below:

  1. Use a component and define spec.input.<something> and set it to type map (see code block above)
  2. Add variables when including the job
     - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/example-variables@$CI_COMMIT_SHA
       inputs:
         variables:
           SOME_VARIABLE: "This is some variable."
  3. Check the jobs logs. to see the variables available in the component.
Edited by Jochen

Merge request reports

Loading