Skip to main content
Version: 5.11.x

ConditionExpression

Conditional expressions.

Use to build up a conditional state, and can be composed in novel ways. There must only be one property defined on a single condition, and the terminal must always define an "equals".

Conditions can contain placeholders variables, in the form ${VARIABLE}.

Condition on the task running being successful:

equals:
- "${WORKFLOWS_TASK_RESULT}"
- "success"

Condition on a branch name being "main" or "hotfix":

or:
- equals:
- "${WORKFLOWS_BRANCH_NAME}"
- "main"
- equals:
- "${WORKFLOWS_BRANCH_NAME}"
- "hotfix"

Conditions can also be negated:

not:
equals:
- "${WORKFLOWS_BRANCH_NAME}"
- "main"

Table of contents

Properties

Properties

and

Optional and: ConditionExpression[]

If set, the given conditions must all evaluate truthy for this condition to pass.


not

Optional not: ConditionExpression

If set, the result of the given condition is negated.


or

Optional or: ConditionExpression[]

If set, at least one of the given conditions must evaluate truthy for this condition to pass.

equals

Optional equals: [string, string]

The main "condition" which will evaluate truthy if both sides of the expression are equal.

Note that types are not considered when evaluating equality, and values are coerced to strings.


lt

Optional lt: [string, string]

A less than condition which will evaluate truthy if the RHS value is less than the LHS.

Note that types are not considered when evaluating equality, and values are coerced to numbers.


lte

Optional lte: [string, string]

A less than or equals condition which will evaluate truthy if the RHS value is less than the or equals to LHS.

Note that types are not considered when evaluating equality, and values are coerced to numbers.


gt

Optional gt: [string, string]

A greater than condition which will evaluate truthy if the LHS value is greater than the RHS.

Note that types are not considered when evaluating equality, and values are coerced to numbers.


gte

Optional gte: [string, string]

A greater than condition which will evaluate truthy if the LHS value is greater than the or equals to RHS.

Note that types are not considered when evaluating equality, and values are coerced to numbers.


starts_with

Optional starts_with: [string, string]

A condition that evaluates true if the LHS value starts with the RHS. This expression does not consider case.


ends_with

Optional ends_with: [string, string]

A condition that evaluates true if the LHS value ends with the RHS. This expression does not consider case.


contains

Optional contains: [string, string]

A condition that evaluates true if the LHS value contains the RHS.


is

Optional is: string

A condition that evaluates a single value and returns true if the value is considered truthy.

Examples of truthy values:

  • true (boolean)
  • "string".length > 0
  • n > 0
  • The value may also be a placeholder that will be resolved before evaluation, such as an env var reference or context var.

matches

Optional matches: [string, string]

A condition accepts a reqular expression on the LHS, and checks if it matches against the RHS value, in which case it returns true.


always

Optional always: true

A condition that when set always evaluates true.


never

Optional never: true

A condition that when set never evaluates true.


branches

Optional branches: [string]

A condition that will attempt to match any of the strings against the current branch name.

This will de-sugar into a list of matches conditions that are evaluated with an or.


tags

Optional tags: [string]

A condition that will attempt to match any of the strings against the git tag that triggered this build.

This will de-sugar into a list of matches conditions that are evaluated with an or.


task

Optional task:

A condition that will match against the current task context. When multiple conditions are set, they are or'd together.

  • Optional types: List of task types that are or'd together. The condition will be true if the current task type is contained within this list.

  • Optional primary: If true, the conditional will evaluate true if the current task type is a primary type. A "primary" task is one of the following types:

    - build
    - buildifier
    - configure
    - delivery
    - format
    - gazelle
    - lint
    - test
    - warming
  • Optional secondary: If true, the conditional will evaluate true if the current task type is a secondary type. A "secondary" task is one of the following types:

    - checkout
    - bazel_health_probe
    - finalization