Add type validation to inputs
What does this MR do and why?
This MR adds type validation to CI inputs. The available types are string
, number
, and boolean
. Inputs without an explicit type are type string
by default, which preserves the existing un-typed behavior.
Screenshots or screen recordings
Included template
This CI configuration requires 3 inputs, one from each of the possible types.
Error messages
This configuration passes a number to test_input
when a string is expected.
This configuration passes a string to multiple
when a number is expected.
This configuration passes a string to run_job
when a boolean is expected.
This configuration passes incorrect values to all 3 inputs, so an error message is displayed for each
Working configuration
This configuration passes correct values to all 3 inputs
The included job runs successfully, with this output
How to set up and validate locally
- In a project, create a file
included.yml
with the following configuration:spec: inputs: test_input: type: string multiple: type: number run_job: type: boolean --- included_job: script: - echo "`expr 2 \* $[[ inputs.multiple ]]`" - echo $[[ inputs.test_input ]] - if [ $[[ inputs.run_job ]] = true ] ; then echo 'run_job input is true!' ; fi
- In the CI editor, add the following config
include: local: included.yml inputs: test_input: STRING_HERE multiple: NUMBER_HERE run_job: BOOLEAN_HERE
- Give invalid values to the inputs and see that you get accurate error messages
- Give valid values to the inputs and save the configuration
- Run a pipeline and see that
included_job
runs successfully
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #390458 (closed)