Update Customizing Components authored by Slominski, Ryan's avatar Slominski, Ryan
...@@ -27,4 +27,4 @@ ci-gradle: ...@@ -27,4 +27,4 @@ ci-gradle:
``` ```
## Unsetting Values ## Unsetting Values
Unfortunately there are a few job parameters that have default values that differ when no value is specified vs an empty value is specified, and there is currently no way to "unset/clear" a Component input. For example: `rules` and `needs` behave differently if not specified at all vs an empty array `[]`. The YAML file format suggests that a `null` might be want we want to "unset" the value, but this does not work to clear Component inputs. See: https://gitlab.com/gitlab-org/gitlab/-/issues/439524. In the case of `rules`, you can use `[{when: on_success}]` to force the default behavior as if no rules were provided. This isn't the case with `needs` though - you can't clear it. The work-around is to avoid using `needs` as an input unless it's almost certainly going to be set to something, and if all else fails, users can use `extends` to extend the job defined in the Component as [extended jobs can clear fields](https://docs.gitlab.com/ci/yaml/yaml_optimization/#exclude-a-key-from-extends). Also note, that you'd also have to override the Component job name to prepend a period `.` to mark the parent job as a [hidden job](https://docs.gitlab.com/ci/jobs/#hide-a-job), as otherwise extending from a normal job results in two jobs. Unfortunately there are a few job parameters that have default values that differ when no value is specified vs an empty value is specified, and there is currently no way to "unset/clear" a Component input. For example: `rules` and `needs` behave differently if not specified at all vs an empty array `[]`. The YAML file format suggests that a `null` might be want we want to "unset" the value, but this [does not work to clear Component inputs](https://gitlab.com/gitlab-org/gitlab/-/issues/439524). In the case of `rules`, you can use `[{when: on_success}]` to force the default behavior as if no rules were provided. This isn't the case with `needs` though - you can't clear it. The work-around is to avoid using `needs` as an input unless it's almost certainly going to be set to something, and if all else fails, users can use `extends` to extend the job defined in the Component as [extended jobs can clear fields](https://docs.gitlab.com/ci/yaml/yaml_optimization/#exclude-a-key-from-extends). Also note, that you'd also have to override the Component job name to prepend a period `.` to mark the parent job as a [hidden job](https://docs.gitlab.com/ci/jobs/#hide-a-job), as otherwise extending from a normal job results in two jobs.