Skip to content

Commit

Permalink
Merge pull request #159 from walter-cd/fix-parallel-skip
Browse files Browse the repository at this point in the history
Fix bug not to skip in parallel stages
  • Loading branch information
takahi-i authored Jun 10, 2016
2 parents 13f73a8 + 3fd4fea commit b3943e3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ func (e *Engine) ExecuteStage(stage stages.Stage) {
log.Debugf("Execute as parent name %+v", stage.GetStageName())

mediator := stages.Mediator{States: make(map[string]string)}
mediator.States[stage.GetStageName()] = e.executeStage(stage, mediatorsReceived)
e.executeChildStages(&stage, &mediator)
mediator.States[stage.GetStageName()] = e.executeStage(stage, mediatorsReceived, mediator)

log.Debugf("Sending output of stage: %+v %v", stage.GetStageName(), mediator)
*stage.GetOutputCh() <- mediator
Expand All @@ -112,16 +111,22 @@ func (e *Engine) executeChildStages(stage *stages.Stage, mediator *stages.Mediat
}
}

func (e *Engine) executeStage(stage stages.Stage, received []stages.Mediator) string {
func (e *Engine) executeStage(stage stages.Stage, received []stages.Mediator, mediator stages.Mediator) string {
var result string
if !e.isUpstreamAnyFailure(received) || e.Opts.StopOnAnyFailure {
result = strconv.FormatBool(stage.(stages.Runner).Run())
e.EnvVariables.ExportSpecialVariable("__OUT[\""+stage.GetStageName()+"\"]", stage.GetOutResult())
e.EnvVariables.ExportSpecialVariable("__ERR[\""+stage.GetStageName()+"\"]", stage.GetErrResult())
e.EnvVariables.ExportSpecialVariable("__COMBINED[\""+stage.GetStageName()+"\"]", stage.GetCombinedResult())
e.EnvVariables.ExportSpecialVariable("__RESULT[\""+stage.GetStageName()+"\"]", result)
e.executeChildStages(&stage, &mediator)
} else {
log.Warnf("Execution is skipped: %v", stage.GetStageName())
if childStages := stage.GetChildStages(); childStages.Len() > 0 {
for childStage := childStages.Front(); childStage != nil; childStage = childStage.Next() {
log.Warnf("Execution of child stage is skipped: %v", childStage.Value.(stages.Stage).GetStageName())
}
}
result = "skipped"
}
if !stage.GetSuppressAll() {
Expand Down

0 comments on commit b3943e3

Please sign in to comment.