Skip to content

Commit

Permalink
fix(pipelines): Copying of failed child pipeline outputs (#3186)
Browse files Browse the repository at this point in the history
This fixes an issue where the outputs of a failed stage that calls another pipeline would not be made available in the parent pipeline's subsequent stages.
  • Loading branch information
luispollo authored and marchello2000 committed Sep 23, 2019
1 parent dea4a7f commit 1ae7811
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
]
}
}

0 comments on commit 1ae7811

Please sign in to comment.