Skip to content

Commit

Permalink
fix(expressions): Include evaluation summary in v2
Browse files Browse the repository at this point in the history
- ensure evaluation errors are included in precondition
  • Loading branch information
jeyrschabu committed Oct 6, 2017
1 parent 9084eb7 commit 93dd701
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) + [
Expand All @@ -57,6 +59,13 @@ class ExpressionPreconditionTask implements PreconditionTask {
])
}

private static void ensureEvaluationSummaryIncluded(Map<String, Object> 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"
}
Expand Down

0 comments on commit 93dd701

Please sign in to comment.