Skip to content

Allow a component to reference internal files

Problem

As the author of a pipeline component, when I have complex scripts or code that I want to execute, I need to be able to reference it inside the pipeline component YAML configuration.

Context

In !101762 (comment 1160546702) we discussed the idea of a component to reference internal files in order to make the YAML configuration smaller and more maintainable.

Ideas

The general idea is, if I have scan-x.sh and scan-y.sh scripts that I want to be executed by my component in the context of the hosting pipeline, I need a way for my component to reference the scripts from its own repository.

# the content of gitlab-org/dast component configuration
# An example of possible syntax:
scan-x:
  script:
    - include: scripts/scan-x.sh # inside gitlab-org/dast/scripts directory

scan-y:
  script:
    - include: scripts/scan-y.sh

But we should consider other options too.

Today we evaluate YAML configurations in the context of the hosting pipeline, including run-time evaluation like script:. This is why we inline long complex scripts inside the template YAML today.

A better approach than inlining code, that we use today is building a Docker container with all the dependencies in it, then execute it as a CLI:

Edited by Fabio Pitino