diff --git a/orca-front50/src/main/groovy/com/netflix/spinnaker/orca/front50/tasks/MonitorPipelineTask.groovy b/orca-front50/src/main/groovy/com/netflix/spinnaker/orca/front50/tasks/MonitorPipelineTask.groovy index 4d21a103de..3309565d0b 100644 --- a/orca-front50/src/main/groovy/com/netflix/spinnaker/orca/front50/tasks/MonitorPipelineTask.groovy +++ b/orca-front50/src/main/groovy/com/netflix/spinnaker/orca/front50/tasks/MonitorPipelineTask.groovy @@ -88,7 +88,8 @@ class MonitorPipelineTask implements OverridableTimeoutRetryableTask { return TaskResult.builder(ExecutionStatus.TERMINAL).context([ status : childPipeline.status, exception: exceptionDetails - ]).build() + ]).outputs(childPipeline.getContext()) + .build() } return TaskResult.builder(ExecutionStatus.RUNNING).context([status: childPipeline.status]).build() diff --git a/orca-front50/src/test/groovy/com/netflix/spinnaker/orca/front50/tasks/MonitorPipelineTaskSpec.groovy b/orca-front50/src/test/groovy/com/netflix/spinnaker/orca/front50/tasks/MonitorPipelineTaskSpec.groovy index b3d91278b6..d3bb60a220 100644 --- a/orca-front50/src/test/groovy/com/netflix/spinnaker/orca/front50/tasks/MonitorPipelineTaskSpec.groovy +++ b/orca-front50/src/test/groovy/com/netflix/spinnaker/orca/front50/tasks/MonitorPipelineTaskSpec.groovy @@ -78,12 +78,12 @@ class MonitorPipelineTaskSpec extends Specification { type = PipelineStage.PIPELINE_CONFIG_TYPE name = "pipeline" outputs = [ - artifacts: [ - [type: "docker/image", - reference: "gcr.io/project/my-image@sha256:28f82eba", - name: "gcr.io/project/my-image", - version: "sha256:28f82eba"], - ] + artifacts: [ + [type : "docker/image", + reference: "gcr.io/project/my-image@sha256:28f82eba", + name : "gcr.io/project/my-image", + version : "sha256:28f82eba"], + ] ] } status = ExecutionStatus.SUCCEEDED @@ -150,12 +150,69 @@ class MonitorPipelineTaskSpec extends Specification { ] ], // source should reference the _first_ halted stage in the child pipeline - source: [ + source : [ executionId: pipeline.id, - stageId: pipeline.stages[1].id, - stageName: "a pipeline", - stageIndex: 1 + stageId : pipeline.stages[1].id, + stageName : "a pipeline", + stageIndex : 1 ] ] } + + def "propagates child pipeline outputs"() { + def pipeline = pipeline { + application = "orca" + name = "a pipeline" + stage { + type = PipelineStage.PIPELINE_CONFIG_TYPE + name = "stage with outputs" + outputs = [ + "myVar1": "myValue1", + "myVar2": "myValue2" + ] + } + status = ExecutionStatus.SUCCEEDED + } + + repo.retrieve(*_) >> pipeline + + when: + def result = task.execute(stage) + def outputs = result.outputs + + then: + outputs == [ + "myVar1": "myValue1", + "myVar2": "myValue2" + ] + } + + def "propagates failed child pipeline outputs"() { + def pipeline = pipeline { + application = "orca" + name = "a pipeline" + stage { + type = PipelineStage.PIPELINE_CONFIG_TYPE + name = "failed stage with outputs" + outputs = [ + "myVar1": "myValue1", + "myVar2": "myValue2" + ] + status = ExecutionStatus.TERMINAL + } + status = ExecutionStatus.TERMINAL + } + + repo.retrieve(*_) >> pipeline + + when: + def result = task.execute(stage) + def outputs = result.outputs + + then: + outputs == [ + "myVar1": "myValue1", + "myVar2": "myValue2" + ] + } }