From 99a42c4a9c0202270b301f2814c30a304f63f361 Mon Sep 17 00:00:00 2001 From: Mark Vulfson Date: Wed, 15 May 2019 21:53:40 -0700 Subject: [PATCH] fix(MPTv1): Fix template expansion (#2918) With kork-bom, we have picked up a new version of jinjava (despite the force=true directive to gradle which doesn't work in bom scenarios where first one wins) Anyway, old jinjava would handle missing variables by evaluating the expression to false; new jinjava throws. When a stage has a `{when}` condition that uses a variable that was part of the stage config that variable doesn't get added to the context until we process the stage the second time! Add those variables to the context on the first time round to make template expansion happy --- orca-pipelinetemplate/orca-pipelinetemplate.gradle | 5 +---- .../v1schema/graph/transform/RenderTransform.java | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/orca-pipelinetemplate/orca-pipelinetemplate.gradle b/orca-pipelinetemplate/orca-pipelinetemplate.gradle index 6b1288de0f..8b41fc711b 100644 --- a/orca-pipelinetemplate/orca-pipelinetemplate.gradle +++ b/orca-pipelinetemplate/orca-pipelinetemplate.gradle @@ -8,10 +8,7 @@ dependencies { implementation(project(":orca-front50")) implementation(project(":orca-clouddriver")) - implementation("com.hubspot.jinjava:jinjava:2.2.3") { - force = true - } - + implementation("com.hubspot.jinjava:jinjava") implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("com.jayway.jsonpath:json-path:2.2.0") diff --git a/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/graph/transform/RenderTransform.java b/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/graph/transform/RenderTransform.java index c0bdcbfb50..ff4da8a9a0 100644 --- a/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/graph/transform/RenderTransform.java +++ b/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/graph/transform/RenderTransform.java @@ -186,6 +186,7 @@ private void renderStage(StageDefinition stage, RenderContext context, String lo .withCause("Received type " + rendered.getClass().toString()) .withLocation(context.getLocation())); } + context.getVariables().putAll((Map) rendered); stage.setConfig((Map) rendered); stage.setName(