diff --git a/pkg/pipeline/PipelineStageService.go b/pkg/pipeline/PipelineStageService.go index 77c27219f9..520cf92f60 100644 --- a/pkg/pipeline/PipelineStageService.go +++ b/pkg/pipeline/PipelineStageService.go @@ -80,11 +80,12 @@ func (impl *PipelineStageServiceImpl) BuildCiStageDataDeepCopy(ciStage *reposito var stepsDto []*bean.PipelineStageStepDto for _, step := range steps { stepDto := &bean.PipelineStageStepDto{ - Name: step.Name, - Index: step.Index, - Description: step.Description, - OutputDirectoryPath: step.OutputDirectoryPath, - StepType: step.StepType, + Name: step.Name, + Index: step.Index, + Description: step.Description, + OutputDirectoryPath: step.OutputDirectoryPath, + StepType: step.StepType, + TriggerIfParentStageFail: step.TriggerIfParentStageFail, } if step.StepType == repository.PIPELINE_STEP_TYPE_INLINE { inlineStepDetail, err := impl.BuildInlineStepDataDeepCopy(step) @@ -239,12 +240,6 @@ func (impl *PipelineStageServiceImpl) BuildVariableAndConditionDataByStepIdDeepC return inputVariablesDto, outputVariablesDto, conditionsDto, nil } - - - - - - //GetCiPipelineStageData and related methods starts func (impl *PipelineStageServiceImpl) GetCiPipelineStageData(ciPipelineId int) (*bean.PipelineStageDto, *bean.PipelineStageDto, error) { @@ -292,12 +287,13 @@ func (impl *PipelineStageServiceImpl) BuildCiStageData(ciStage *repository.Pipel var stepsDto []*bean.PipelineStageStepDto for _, step := range steps { stepDto := &bean.PipelineStageStepDto{ - Id: step.Id, - Name: step.Name, - Index: step.Index, - Description: step.Description, - OutputDirectoryPath: step.OutputDirectoryPath, - StepType: step.StepType, + Id: step.Id, + Name: step.Name, + Index: step.Index, + Description: step.Description, + OutputDirectoryPath: step.OutputDirectoryPath, + StepType: step.StepType, + TriggerIfParentStageFail: step.TriggerIfParentStageFail, } if step.StepType == repository.PIPELINE_STEP_TYPE_INLINE { inlineStepDetail, err := impl.BuildInlineStepData(step) @@ -528,6 +524,7 @@ func (impl *PipelineStageServiceImpl) CreateStageSteps(steps []*bean.PipelineSta UpdatedOn: time.Now(), UpdatedBy: userId, }, + TriggerIfParentStageFail: step.TriggerIfParentStageFail, } inlineStep, err = impl.pipelineStageRepository.CreatePipelineStageStep(inlineStep) if err != nil { @@ -556,6 +553,7 @@ func (impl *PipelineStageServiceImpl) CreateStageSteps(steps []*bean.PipelineSta UpdatedOn: time.Now(), UpdatedBy: userId, }, + TriggerIfParentStageFail: step.TriggerIfParentStageFail, } refPluginStep, err := impl.pipelineStageRepository.CreatePipelineStageStep(refPluginStep) if err != nil { @@ -947,6 +945,7 @@ func (impl *PipelineStageServiceImpl) UpdateStageSteps(steps []*bean.PipelineSta UpdatedOn: time.Now(), UpdatedBy: userId, }, + TriggerIfParentStageFail: step.TriggerIfParentStageFail, } var inputVariables []*bean.StepVariableDto var outputVariables []*bean.StepVariableDto @@ -1552,10 +1551,11 @@ func (impl *PipelineStageServiceImpl) GetRefPluginStepsByIds(refPluginIds []int, func (impl *PipelineStageServiceImpl) BuildCiStepDataForWfRequest(step *repository.PipelineStageStep) (*bean.StepObject, error) { stepData := &bean.StepObject{ - Name: step.Name, - Index: step.Index, - StepType: string(step.StepType), - ArtifactPaths: step.OutputDirectoryPath, + Name: step.Name, + Index: step.Index, + StepType: string(step.StepType), + ArtifactPaths: step.OutputDirectoryPath, + TriggerIfParentStageFail: step.TriggerIfParentStageFail, } if step.StepType == repository.PIPELINE_STEP_TYPE_INLINE { //get script and mapping data diff --git a/pkg/pipeline/bean/pipelineStage.go b/pkg/pipeline/bean/pipelineStage.go index 3fbfef9487..2e64284e2d 100644 --- a/pkg/pipeline/bean/pipelineStage.go +++ b/pkg/pipeline/bean/pipelineStage.go @@ -14,14 +14,15 @@ type PipelineStageDto struct { } type PipelineStageStepDto struct { - Id int `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - Index int `json:"index"` - StepType repository.PipelineStepType `json:"stepType" validate:"omitempty,oneof=INLINE REF_PLUGIN"` - OutputDirectoryPath []string `json:"outputDirectoryPath"` - InlineStepDetail *InlineStepDetailDto `json:"inlineStepDetail"` - RefPluginStepDetail *RefPluginStepDetailDto `json:"pluginRefStepDetail"` + Id int `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Index int `json:"index"` + StepType repository.PipelineStepType `json:"stepType" validate:"omitempty,oneof=INLINE REF_PLUGIN"` + OutputDirectoryPath []string `json:"outputDirectoryPath"` + InlineStepDetail *InlineStepDetailDto `json:"inlineStepDetail"` + RefPluginStepDetail *RefPluginStepDetailDto `json:"pluginRefStepDetail"` + TriggerIfParentStageFail bool `json:"triggerIfParentStageFail"` } type InlineStepDetailDto struct { diff --git a/pkg/pipeline/bean/workFlowRequestBean.go b/pkg/pipeline/bean/workFlowRequestBean.go index c1169ca1cb..702b613a7e 100644 --- a/pkg/pipeline/bean/workFlowRequestBean.go +++ b/pkg/pipeline/bean/workFlowRequestBean.go @@ -34,6 +34,7 @@ type StepObject struct { SourceCodeMount *MountPath `json:"sourceCodeMount"` // destination path - mountCodeToContainerPath ExtraVolumeMounts []*MountPath `json:"extraVolumeMounts"` // filePathMapping ArtifactPaths []string `json:"artifactPaths"` + TriggerIfParentStageFail bool `json:"triggerIfParentStageFail"` } type VariableObject struct { diff --git a/pkg/pipeline/repository/PipelineStageRepository.go b/pkg/pipeline/repository/PipelineStageRepository.go index f6403aa67e..d936e6cfc3 100644 --- a/pkg/pipeline/repository/PipelineStageRepository.go +++ b/pkg/pipeline/repository/PipelineStageRepository.go @@ -50,18 +50,19 @@ type PipelineStage struct { } type PipelineStageStep struct { - tableName struct{} `sql:"pipeline_stage_step" pg:",discard_unknown_columns"` - Id int `sql:"id,pk"` - PipelineStageId int `sql:"pipeline_stage_id"` - Name string `sql:"name"` - Description string `sql:"description"` - Index int `sql:"index"` - StepType PipelineStepType `sql:"step_type"` - ScriptId int `sql:"script_id"` - RefPluginId int `sql:"ref_plugin_id"` //id of plugin used as reference - OutputDirectoryPath []string `sql:"output_directory_path" pg:",array"` - DependentOnStep string `sql:"dependent_on_step"` - Deleted bool `sql:"deleted,notnull"` + tableName struct{} `sql:"pipeline_stage_step" pg:",discard_unknown_columns"` + Id int `sql:"id,pk"` + PipelineStageId int `sql:"pipeline_stage_id"` + Name string `sql:"name"` + Description string `sql:"description"` + Index int `sql:"index"` + StepType PipelineStepType `sql:"step_type"` + ScriptId int `sql:"script_id"` + RefPluginId int `sql:"ref_plugin_id"` //id of plugin used as reference + OutputDirectoryPath []string `sql:"output_directory_path" pg:",array"` + DependentOnStep string `sql:"dependent_on_step"` + Deleted bool `sql:"deleted,notnull"` + TriggerIfParentStageFail bool `sql:"trigger_if_parent_stage_fail"` sql.AuditLog } diff --git a/scripts/sql/120_trigger_post_ci_if_ci_fail.down.sql b/scripts/sql/120_trigger_post_ci_if_ci_fail.down.sql new file mode 100644 index 0000000000..2e59716be5 --- /dev/null +++ b/scripts/sql/120_trigger_post_ci_if_ci_fail.down.sql @@ -0,0 +1,2 @@ +---- drop trigger_if_parent_stage_fail column +ALTER TABLE pipeline_stage_step DROP COLUMN IF EXISTS trigger_if_parent_stage_fail; \ No newline at end of file diff --git a/scripts/sql/120_trigger_post_ci_if_ci_fail.up.sql b/scripts/sql/120_trigger_post_ci_if_ci_fail.up.sql new file mode 100644 index 0000000000..07608a0a38 --- /dev/null +++ b/scripts/sql/120_trigger_post_ci_if_ci_fail.up.sql @@ -0,0 +1,2 @@ +---- add trigger_if_parent_stage_fail column +ALTER TABLE pipeline_stage_step ADD COLUMN IF NOT EXISTS trigger_if_parent_stage_fail bool; \ No newline at end of file