​Develop a ​Condition

Here is how you can develop a new Condition.

Here is a simple condition example that validate the current flow:

    title = "Condition for a specific flow"
    examples = {
            full = true,
            code = {
                "- conditions:",
                "    - type: io.kestra.core.models.conditions.types.FlowCondition",
                "      namespace: io.kestra.tests",
                "      flowId: my-current-flow"
public class FlowCondition extends Condition {
    @Schema(title = "The namespace of the flow")
    public String namespace;

    @Schema(title = "The flow id")
    public String flowId;

    public boolean test(ConditionContext conditionContext) {
        return conditionContext.getFlow().getNamespace().equals(this.namespace) && conditionContext.getFlow().getId().equals(this.flowId);

You just need to extend Condition and implement the boolean test(ConditionContext conditionContext) method.

You can have any properties you want like for any task (validation, documentation, ...), everything is working the same way.

The test will receive a ConditionContext that will expose:

  • conditionContext.getFlow(): the current flow.
  • conditionContext.getExecution(): the current execution that can be null for Triggers.
  • conditionContext.getRunContext(): a RunContext in order to render your properties.

This method must simply return a boolean in order to validate or not the condition.


Remember to document your conditions. For this, we provide a set of annotations explained in the Document each plugin section.