switch

The switch step allows decision logic in the process. It expands a variable by name or evaluates an expression containing a 'p' expression to a value. Based on the value, one case is selected and its actions are carried out.

Format

switch step "foo" is
    -- a variable or ${p:expression} to evaluate
    evaluate "variable"

-- case selected if the expression evaluates to "A"
on case "A"
    -- one or more start commands
    start "step-a"

-- additional cases follow
on case "B"
    start "step-b"

-- case selected if no other expression matches; optional
-- if present, this must be the final option
on default
    start "step-default"
end

Properties

Table 1. Switch properties
Field Description
Name A name for the step. Other process steps can refer to this step by this name.
Property Name The property to use for the branching. You can specify the property name by itself or in the same form as you would use in other steps, such as ${p:propertyName}. You cannot use a secure property in this field.

Example

start is
    start A
    start B
    start C
    start D
    start E
end

switch step A is
    evaluate prop-name-a
on case case-a1
    start case-a1-step
on case case-a2
    start case-a2-step
on default
    finish
end

switch step B is
    evaluate prop-name-b
on default
    finish
end

switch step C is
    evaluate prop-name-c
on case case-c1
    finish
end

switch step D is
    evaluate prop-name-d
end

switch step E is
    evaluate "${p:prop-name-e}"
end

shell step case-a1-step is
    "echo case-a1-step"
on success
    finish
end

shell step case-a2-step is
    "echo case-a2-step"
on success
    finish
end