Skip to content

Use `null` CI input value to remove parent node

Avielle Wolfe requested to merge 440468-null-for-inputs into master

What does this MR do and why?

This commit implements the ability to pass null to a CI input of any type. If that input is used as the only value of a key, the key will be removed from the config. Users have requested this feature so they can write components in a way that allows consumers of the component to decide whether they want a job in the component to have needs, rules, parallel, etc.

Changelog: added

Issue: #440468

How to set up and validate locally

  1. In any project, create a file included.yml with this content:
    spec:
      inputs:
        build_needs:
          type: array
          default: null
        test_needs:
          type: array
        deploy_needs:
          type: array
    
    ---
    
    build:
      script: echo "$[[ inputs.build_needs ]]"
      needs: $[[ inputs.build_needs ]]
    
    test:
      script: echo "$[[ inputs.test_needs ]]"
      needs: $[[ inputs.test_needs ]]
    
    deploy:
      script: echo "$[[ inputs.deploy_needs ]]"
      needs: $[[ inputs.deploy_needs ]]
  2. Paste this configuration into the project's CI editor:
    include:
      - local: included.yml
        inputs:
          test_needs: null
          deploy_needs: ['build', 'test']
  3. See that you get this merged YAML:
    build:
      script: echo ""
    test:
      script: echo ""
    deploy:
      script: echo "["build", "test"]"
      needs:
       - build
       - test
Edited by Avielle Wolfe

Merge request reports