From 363095fed2fc09e1dec58156a978ecb4ff592a92 Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Fri, 28 Feb 2020 09:30:37 -0600 Subject: [PATCH] Allow setting multiple passthrough variables at once Improve Docker and Docker Compose DSLs when setting more than one variable to pass through from the pipeline. --- .buildkite/pipeline.extra-steps.gradle | 6 ++++++ .../plugins/buildkite/BuildkitePipeline.groovy | 16 +++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.buildkite/pipeline.extra-steps.gradle b/.buildkite/pipeline.extra-steps.gradle index bd92d91..3ade4f9 100644 --- a/.buildkite/pipeline.extra-steps.gradle +++ b/.buildkite/pipeline.extra-steps.gradle @@ -29,6 +29,12 @@ commandStep { // Common Buildkite plugins are also part of the DSL. dockerCompose { run 'unit' + // Passthrough variables + environment( + 'FOO', + 'BAR', + 'BAZ', + ) } } diff --git a/buildSrc/src/main/groovy/com/widen/plugins/buildkite/BuildkitePipeline.groovy b/buildSrc/src/main/groovy/com/widen/plugins/buildkite/BuildkitePipeline.groovy index 5075d7b..79fe91b 100644 --- a/buildSrc/src/main/groovy/com/widen/plugins/buildkite/BuildkitePipeline.groovy +++ b/buildSrc/src/main/groovy/com/widen/plugins/buildkite/BuildkitePipeline.groovy @@ -259,12 +259,12 @@ class BuildkitePipeline implements ConfigurableEnvironment { } /** - * Set an environment variable to pass into the Docker container. + * Set one or more environment variables to pass into the Docker container. * - * @param name The variable name. + * @param name The variable names. */ - void environment(String name) { - model.get('environment', []) << name + void environment(String... names) { + model.get('environment', []).addAll(names) } /** @@ -383,10 +383,12 @@ class BuildkitePipeline implements ConfigurableEnvironment { } /** - * Set an environment variable to pass into the container. + * Set one or more environment variables to pass into the Docker container. + * + * @param name The variable names. */ - void environment(String name) { - model.get('env', []) << name + void environment(String... names) { + model.get('env', []).addAll(names) } /**