diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/ElementAdditionalOptions.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/ElementAdditionalOptions.kt index 10edebac3be..eb1713a7760 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/ElementAdditionalOptions.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/ElementAdditionalOptions.kt @@ -53,7 +53,7 @@ data class ElementAdditionalOptions( enum class RunCondition { PRE_TASK_SUCCESS, // 所有前置插件运行成功时 PRE_TASK_FAILED_BUT_CANCEL, // 即使前面有插件运行失败也运行,除非被取消才不运行 - PRE_TASK_FAILED_EVEN_CANCEL, // 即使前面有插件运行失败也运行,即使被取消也运行 [未实现] + PRE_TASK_FAILED_EVEN_CANCEL, // 即使前面有插件运行失败也运行,即使被取消也运行 PRE_TASK_FAILED_ONLY, // 只有前面有插件运行失败时才运行 OTHER_TASK_RUNNING, // 指定插件开始运行时 [未实现] CUSTOM_VARIABLE_MATCH, // 自定义变量全部满足时运行 diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/utils/ModelUtils.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/utils/ModelUtils.kt index 44bb40c82d6..059c2ca5ba3 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/utils/ModelUtils.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/utils/ModelUtils.kt @@ -142,7 +142,8 @@ object ModelUtils { element.canRetry = null // 自动跳过的不能手动重试 } } else if (additionalOptions.runCondition == RunCondition.PRE_TASK_FAILED_ONLY || - additionalOptions.runCondition == RunCondition.PRE_TASK_FAILED_BUT_CANCEL + additionalOptions.runCondition == RunCondition.PRE_TASK_FAILED_BUT_CANCEL || + additionalOptions.runCondition == RunCondition.PRE_TASK_FAILED_EVEN_CANCEL ) { // 前面有失败的插件时也要运行的插件,将前面的失败插件置为不可重试和跳过 element.canRetry = null diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/control/ControlUtils.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/control/ControlUtils.kt index ddf8d4641a0..3a40e7ceeda 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/control/ControlUtils.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/control/ControlUtils.kt @@ -162,7 +162,7 @@ object ControlUtils { additionalOptions?.runCondition == RunCondition.PRE_TASK_FAILED_BUT_CANCEL -> { skip = containerFinalStatus.isCancel() } - // 即使前面有插件运行失败也运行,即使被取消也运行 [未实现] 永远不跳过 + // 即使前面有插件运行失败也运行,即使被取消也运行, 永远不跳过 additionalOptions?.runCondition == RunCondition.PRE_TASK_FAILED_EVEN_CANCEL -> skip = false // 如果容器是失败状态,[其他条件] 都要跳过不执行 containerFinalStatus.isFailure() -> skip = true diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/TaskBuildDetailService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/TaskBuildDetailService.kt index f482f60f417..8b527888ce9 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/TaskBuildDetailService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/TaskBuildDetailService.kt @@ -36,6 +36,7 @@ import com.tencent.devops.common.pipeline.container.Container import com.tencent.devops.common.pipeline.container.Stage import com.tencent.devops.common.pipeline.enums.BuildStatus import com.tencent.devops.common.pipeline.pojo.element.Element +import com.tencent.devops.common.pipeline.pojo.element.RunCondition import com.tencent.devops.common.pipeline.pojo.element.agent.ManualReviewUserTaskElement import com.tencent.devops.common.pipeline.pojo.element.quality.QualityGateInElement import com.tencent.devops.common.pipeline.pojo.element.quality.QualityGateOutElement @@ -294,7 +295,7 @@ class TaskBuildDetailService( val startIndex = endElementIndex + 1 val endIndex = elements.size - 1 if (endIndex >= startIndex) { - addUpdateTaskStatusInfo( + addCancelTaskStatusInfo( startIndex = startIndex, endIndex = endIndex, elements = elements, @@ -322,7 +323,7 @@ class TaskBuildDetailService( val parentElement = elements[parentElementJobIndex] val taskStatus = BuildStatus.parse(parentElement.status) if (!(taskStatus.isFinish() || parentElement.id == endElement.id)) { - handleUpdateTaskStatusInfo( + handleCancelTaskStatusInfo( tmpElementIndex = tmpElementIndex, elements = elements, endElementIndex = endElementIndex, @@ -336,7 +337,7 @@ class TaskBuildDetailService( if (endIndex < startIndex) { return true } - addUpdateTaskStatusInfo( + addCancelTaskStatusInfo( startIndex = startIndex, endIndex = endIndex, elements = elements, @@ -347,7 +348,7 @@ class TaskBuildDetailService( return false } - private fun handleUpdateTaskStatusInfo( + private fun handleCancelTaskStatusInfo( tmpElementIndex: Int, elements: List, endElementIndex: Int, @@ -357,7 +358,7 @@ class TaskBuildDetailService( val startIndex = endElementIndex + 1 val endIndex = elements.size - 1 if (endIndex > startIndex) { - addUpdateTaskStatusInfo( + addCancelTaskStatusInfo( startIndex = startIndex, endIndex = endIndex, elements = elements, @@ -367,21 +368,23 @@ class TaskBuildDetailService( } } - private fun addUpdateTaskStatusInfo( + private fun addCancelTaskStatusInfo( startIndex: Int, endIndex: Int, elements: List, updateTaskStatusInfos: MutableList>? ) { for (i in startIndex..endIndex) { - val unExecElement = elements[i] - val unExecTaskId = unExecElement.id - val unExecBuildStatus = BuildStatus.UNEXEC - unExecElement.status = unExecBuildStatus.name - if (unExecTaskId != null) { + val element = elements[i] + val taskId = element.id + val runCondition = element.additionalOptions?.runCondition + if (taskId != null && runCondition != RunCondition.PRE_TASK_FAILED_EVEN_CANCEL) { + // 把runCondition不为PRE_TASK_FAILED_EVEN_CANCEL的任务的状态置为UNEXEC + val unExecBuildStatus = BuildStatus.UNEXEC + element.status = unExecBuildStatus.name updateTaskStatusInfos?.add( mapOf( - PIPELINE_ELEMENT_ID to unExecTaskId, + PIPELINE_ELEMENT_ID to taskId, BUILD_STATUS to unExecBuildStatus ) )