From 4dc2edd0922f2f9d248d61eb96403cd1d68e833d Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Wed, 3 Apr 2019 10:41:31 -0500 Subject: [PATCH] Add ability to set pipeline-wide variables --- .../com/widen/plugins/UploadPipeline.groovy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/buildSrc/src/main/groovy/com/widen/plugins/UploadPipeline.groovy b/buildSrc/src/main/groovy/com/widen/plugins/UploadPipeline.groovy index 47ce3b9..4537320 100644 --- a/buildSrc/src/main/groovy/com/widen/plugins/UploadPipeline.groovy +++ b/buildSrc/src/main/groovy/com/widen/plugins/UploadPipeline.groovy @@ -14,6 +14,7 @@ class UploadPipeline extends DefaultTask { private static final String DOCKER_PLUGIN_VERSION = 'v1.1.1' private static final String DOCKER_COMPOSE_PLUGIN_VERSION = 'v2.3.0' + private final Map env = [:] private final List steps = [] /** @@ -26,6 +27,20 @@ class UploadPipeline extends DefaultTask { */ boolean replace = false + /** + * Add an environment variable to apply to all steps. + */ + void environment(String name, String value) { + env.put(name, value) + } + + /** + * Add a map of environment variables to apply to all steps. + */ + void environment(Map variables) { + env.putAll(variables) + } + /** * Add a command step to the pipeline. * @@ -75,6 +90,7 @@ class UploadPipeline extends DefaultTask { */ String toJson() { return JsonOutput.toJson([ + env: env, steps: steps ]) }