Drone

Plugins with nested settings

Is it possible to write a plugin that expects a nested key / value settings Map?

e.g.

kind: pipeline
type: docker
name: default

steps:
  - name: "custom:plugin"
    image: plugins/my-plugin
    settings:
      foo:
        one: 1
        two: "two"
        three: 50.5
      bar:
        hello: 'world'
        example: "true"
        version: "v1.1.1"

If yes, what would the env var PLUGIN_FOO and PLUGIN_BAR contain? I would assume:

{ foo: 1, two: "two", three: 50.5 }

{ hello: 'world', example: "true", version: "v1.1.1" }

yes, complex structures are converted to json strings

Great! Is this documented anywhere? Happy to PR the docs, couldn’t find it myself before asking here.

Primitive types and arrays of primitive types are officially supported. Complex types are informally supported which is why you will not find it documented. The feature is subject to change or even removal (although unlikely). I do envision us changing the behavior slightly to only support maps of primitive types to prevent creating or nesting more complex strictures.

1 Like