-
Notifications
You must be signed in to change notification settings - Fork 257
Description
If BuildCondition.getCombinedResult is called in relation to a stage, then its Object context parameter can be either a Stage instance or the name of the stage as a String. BuildCondition.getCombinedResult however recognizes only the String type and not the Stage type. If a Stage instance is passed in, then BuildCondition.getCombinedResult does not search for a WarningAction in the stage, and might compute an incorrect Result.
I found this while looking at the source code for the sake of JENKINS-68281. I have not reproduced the problem in practice.
- Stage instance: ModelInterpreter.executeSingleStage calls Root.hasSatisfiedConditions, which calls AbstractBuildConditionResponder.satisfiedConditions, which calls BuildCondition.meetsCondition(Object runWrapperObj, Object context, Throwable error), which calls BuildCondition.meetsCondition(WorkflowRun r, Object context, Throwable error), which is overridden by Success.meetsCondition, which calls BuildCondition.combineResults, which calls BuildCondition.getCombinedResult, which does not recognize the Stage type.
- Name of the stage as a String: ModelInterpreter.runPostConditions calls BuildCondition.getCombinedResult, which recognizes the String type.
This inconsistency came from PR #330 for JENKINS-57826.
Originally reported by kon, imported from: Object context in BuildCondition.meetsCondition is sometimes a Stage instance, which is not recognized by BuildCondition.getCombinedResult
- status: Open
- priority: Minor
- component(s): pipeline-model-definition-plugin
- resolution: Unresolved
- votes: 0
- watchers: 1
- imported: 2025-12-06
Raw content of original issue
If BuildCondition.getCombinedResult is called in relation to a stage, then its Object context parameter can be either a Stage instance or the name of the stage as a String. BuildCondition.getCombinedResult however recognizes only the String type and not the Stage type. If a Stage instance is passed in, then BuildCondition.getCombinedResult does not search for a WarningAction in the stage, and might compute an incorrect Result.
I found this while looking at the source code for the sake of
JENKINS-68281. I have not reproduced the problem in practice.
- Stage instance: ModelInterpreter.executeSingleStage calls Root.hasSatisfiedConditions, which calls AbstractBuildConditionResponder.satisfiedConditions, which calls BuildCondition.meetsCondition(Object runWrapperObj, Object context, Throwable error), which calls BuildCondition.meetsCondition(WorkflowRun r, Object context, Throwable error), which is overridden by Success.meetsCondition, which calls BuildCondition.combineResults, which calls BuildCondition.getCombinedResult, which does not recognize the Stage type.
- Name of the stage as a String: ModelInterpreter.runPostConditions calls BuildCondition.getCombinedResult, which recognizes the String type.
This inconsistency came from PR #330 for JENKINS-57826.
- environment:
Pipeline: Declarative 1.9.3