Plugin Parameters

by bradrydzewski

Plugin parameters are used to configure plugin behavior and are defined in the yaml file. This is an example plugin configuration for the Docker plugin:

pipeline:
  publish:
    image: plugin/docker
    repo: foo/bar
    tags:
      - latest
      - prod

Plugin parameters are converted to environment variables and prefixed with PLUGIN_. The above parameters would be converted to the following environment variables:

PLUGIN_REPO=foo/bar
PLUGIN_TAGS=latest,prod

These environment variables are provided to the plugin container at runtime. This would be the equivalent of running the following Docker command:

docker run \
  -e PLUGIN_REPO=foo/bar \
  -e PLUGIN_TAGS=latest,prod \
  plugin/docker

Primitive Types

Primitive types are converted to their string representation and passed to the plugin as environment variables. Example Yaml configuration:

path: path/to/coverage.out
increase: true
threshold: 95.0

Environment variable representation:

PLUGIN_PATH=path/to/coverage.out
PLUGIN_INCREASE=true
PLUGIN_THRESHOLD=95.0

Slice Types

Slices of primitive types are converted to their comma-separated string representation and passed to the plugin as environment variables. Example Yaml configuration:

tags: [ latest, 1.0, 1.0.0 ]

Environment variable representation:

PLUGIN_TAGS=latest,1.0,1.0.0

Complex Types

Complex types are serialized to a JSON string and passed to the plugin as environment variables. The plugin is responsible for unmarshaling the value. Example Yaml configuration:

basic_auth:
  username: octocat
  password: pa55word

Environment variable representation:

PLUGIN_BASIC_AUTH={"username": "octocat", "password": "pa55word"}