From 93dd701553e9ca93c2509b984e056b722dd07a88 Mon Sep 17 00:00:00 2001 From: jeyrs Date: Thu, 5 Oct 2017 22:56:51 -0700 Subject: [PATCH] fix(expressions): Include evaluation summary in v2 - ensure evaluation errors are included in precondition --- .../pipeline/tasks/ExpressionPreconditionTask.groovy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/tasks/ExpressionPreconditionTask.groovy b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/tasks/ExpressionPreconditionTask.groovy index d61179c97e8..d2ccf15792e 100644 --- a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/tasks/ExpressionPreconditionTask.groovy +++ b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/tasks/ExpressionPreconditionTask.groovy @@ -19,6 +19,7 @@ package com.netflix.spinnaker.orca.pipeline.tasks import com.netflix.spinnaker.orca.ExecutionStatus import com.netflix.spinnaker.orca.TaskResult +import com.netflix.spinnaker.orca.pipeline.expressions.PipelineExpressionEvaluator import com.netflix.spinnaker.orca.pipeline.model.Stage import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor import org.springframework.beans.factory.annotation.Autowired @@ -49,6 +50,7 @@ class ExpressionPreconditionTask implements PreconditionTask { expression = matcher.group(1) } + ensureEvaluationSummaryIncluded(result, stage, expression) def status = Boolean.valueOf(expression) ? ExecutionStatus.SUCCEEDED : ExecutionStatus.TERMINAL return new TaskResult(status, [ context: new HashMap(stage.context.context as Map) + [ @@ -57,6 +59,13 @@ class ExpressionPreconditionTask implements PreconditionTask { ]) } + private static void ensureEvaluationSummaryIncluded(Map result, Stage stage, String expression) { + if (!expression.trim().startsWith('$') && PipelineExpressionEvaluator.SUMMARY in result) { + stage.context[PipelineExpressionEvaluator.SUMMARY] = PipelineExpressionEvaluator.SUMMARY in stage.context ? + stage.context[PipelineExpressionEvaluator.SUMMARY] + result[PipelineExpressionEvaluator.SUMMARY] : result[PipelineExpressionEvaluator.SUMMARY] + } + } + static class StageData { String expression = "false" }