Module Gitlab_ci.If

GitLab CI variable expressions

For more information, see here.

type t

Predicates for GitLab if: expression, as used in rules: clauses.

type term

Terms for predicates in GitLab if: clauses.

val encode : t -> string

The string representation of an if: expression.

val var : string -> Var.t

var name is the if: expression $name.

This is an alias of Var.make to simplify usage of variables in if: expressions. It allows you to write e.g. { If.(var "foo" == "bar")

}

instead of { If.(Var.make "foo" == "bar")

}

Raises Invalid_argument if the variable name is not composed exclusively of characters from the set a-zA-Z0-9_.

val str : string -> term

str s is the if: expression "s".

Raises Invalid_argument if the literal string contains both single and double quotes. Such strings cannot be encoded in GitLab CI if: expressions.

val null : term

The if:-expression null.

val (==) : Var.t -> term -> t

Equality in if:-expressions.

Example: var "foo" == str "bar" translates to $foo == "bar".

val (!=) : Var.t -> term -> t

Inequality in if:-expressions.

Example: var "foo" != str "bar" translates to $foo != "bar".

val (&&) : t -> t -> t

Conjunction of if:-expressions.

val (||) : t -> t -> t

Disjunction of if:-expressions.

val (=~) : Var.t -> string -> t

Pattern match on if:-expressions.

Example: var "foo" =~ str "/bar/" translates to $foo =~ "/bar/".

val (=~!) : Var.t -> string -> t

Negated pattern match on if:-expressions.

Example: var "foo" =~! str "/bar/" translates to $foo !~ "/bar/".

val not : t -> t

Negation of a predicate.

If t evaluates to true, then not t evaluates to false. Note that if: expressions have no native negation operator. Therefore this function works by rewriting the expression using de Morgan's laws and swapping (negated) operators for their (un)negated counter-parts.