From 4c957bffb1566b8fbf6d9ce22584e19897c81517 Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Wed, 31 Jul 2019 11:31:46 -0500 Subject: [PATCH] Tweak environment block resolve strategy to be more ergonomic --- .../plugins/buildkite/ConfigurableEnvironment.groovy | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/groovy/com/widen/plugins/buildkite/ConfigurableEnvironment.groovy b/buildSrc/src/main/groovy/com/widen/plugins/buildkite/ConfigurableEnvironment.groovy index 240e063..dc9b996 100644 --- a/buildSrc/src/main/groovy/com/widen/plugins/buildkite/ConfigurableEnvironment.groovy +++ b/buildSrc/src/main/groovy/com/widen/plugins/buildkite/ConfigurableEnvironment.groovy @@ -22,9 +22,11 @@ trait ConfigurableEnvironment { * Set environment variables using a configure block. */ void environment(@DelegatesTo(Map) Closure closure) { - [:].with { - with(closure) - environment(it) - } + def map = [:] + closure = (Closure) closure.clone() + closure.delegate = map + closure.resolveStrategy = Closure.OWNER_FIRST + closure() + environment(map) } }