Skip to content

Commit

Permalink
fix(findImage) : Fix findImage bug introduced in #2960 (#2980)
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindmd committed Jun 12, 2019
1 parent 62346e4 commit 7819d26
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ trait DeploymentDetailsAware {
Closure callback) {
Stage previousStage = getPreviousStageWithImage(stage, targetRegion, targetCloudProvider)
def result = [:]
if (previousStage) {
if (previousStage && isCloudProviderEqual(stage, previousStage)) {
if (previousStage.context.containsKey("amiDetails")) {
def amiDetail = previousStage.context.amiDetails.find {
!targetRegion || it.region == targetRegion
Expand Down Expand Up @@ -81,20 +81,17 @@ trait DeploymentDetailsAware {
}
}

boolean isCloudProviderEqual(Stage stage, Stage execution){
if(execution.context.cloudProvider!=null) {
return execution.context.cloudProvider == stage.context.cloudProvider
boolean isCloudProviderEqual(Stage stage, Stage previousStage){
if(previousStage.context.cloudProvider!=null && stage.context.cloudProvider!=null) {
return previousStage.context.cloudProvider == stage.context.cloudProvider
}
return true
}

List<Stage> getAncestors(Stage stage, Execution execution) {
if (stage?.requisiteStageRefIds) {
def previousStages = execution.stages.findAll {
// Include cloudProvider check to avoid confusion with multi-provider,
// in some cases ancestors can be one of any multi-provider
// Eg parent->aws and child->titus
it.refId in stage.requisiteStageRefIds && isCloudProviderEqual(stage,it)
it.refId in stage.requisiteStageRefIds

}
def syntheticStages = execution.stages.findAll {
Expand Down

0 comments on commit 7819d26

Please sign in to comment.