Skip to content

Add boolean and number CI inputs

Avielle Wolfe requested to merge 390458-boolean-and-number-ci-inputs into master

What does this MR do and why?

This MR enables the use of the type keyword with CI inputs and adds boolean and number types. (Previously, inputs could only be strings.)

Changelog: added

Screenshots or screen recordings

This .gitlab-ci.yml file:

Screenshot_2023-07-27_at_17.34.35

Includes this file that has a header defining one input of each valid type:

Screenshot_2023-07-27_at_17.34.18

Which creates this successful job output:

Screenshot_2023-07-27_at_17.34.45

Errors

Errors appear like this:

Screenshot_2023-07-27_at_17.39.43

How to set up and validate locally

  1. Enable the ci_interpolation_inputs_refactor feature flag. The new inputs are not available in the legacy version of the CI inputs code
  2. Add a file included.yml to a project:
    spec:
    inputs:
        test_string:
            type: string
        test_boolean:
            type: boolean
        test_number:
            type: number
    ---
    
    included_job:
        script:
            - echo $[[ inputs.test_string ]]
            - if [ $[[ inputs.test_boolean ]] ]; then echo "it's true!"; fi
            - echo $((8 * $[[ inputs.test_number ]]))
  3. In the pipeline editor, include included.yml and pass invalid input types to see that the validation works
  4. Then pass valid input types and run a pipeline to see that the inputs are used correctly

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #390458 (closed)

Edited by Avielle Wolfe

Merge request reports

Loading