Add split() interpolation function for CI/CD inputs
What does this MR do and why?
Add split() interpolation function for CI/CD inputs
Introduces a new split('<separator>') function to the CI/CD interpolation stack (alongside truncate, expand_vars, posix_escape). The function splits a string input on a separator, strips whitespace from each element, and removes empty segments. Gated behind the ci_interpolation_split_function beta feature flag (disabled by default).
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
How to reproduce
-
Enable the feature flag:
Feature.enable(:ci_interpolation_split_function) -
Create a component or included CI file with a string input:
# .gitlab/ci/deploy.yml spec: inputs: runner_tags: default: 'docker, linux' --- deploy: tags: $[[ inputs.runner_tags | split(',') ]] script: echo "Deploying with tags..." -
Include it in your
.gitlab-ci.yml:include: - local: '.gitlab/ci/deploy.yml' inputs: runner_tags: 'docker, linux, arm64' -
The
tagsfield resolves to['docker', 'linux', 'arm64'](whitespace stripped, empty segments removed).
Error cases to verify:
- Using
split()with a non-string input returns:invalid input type: split can only be used with string inputs - Using an empty separator
split('')returns:invalid argument: separator cannot be empty - Chaining functions after
split()(e.g.,split(',') | truncate(0,1)) returns:split() must be the last function in a chain (it returns an array, not a string)
References
Rollout issue: #603990
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.