Gitlab_ci.If
GitLab CI variable expressions
For more information, see here.
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
.
Equality in if:
-expressions.
Example: var "foo" == str "bar"
translates to $foo == "bar"
.
Inequality in if:
-expressions.
Example: var "foo" != str "bar"
translates to $foo != "bar"
.
Pattern match on if:
-expressions.
Example: var "foo" =~ str "/bar/"
translates to $foo =~ "/bar/"
.
Negated pattern match on if:
-expressions.
Example: var "foo" =~! str "/bar/"
translates to $foo !~ "/bar/"
.
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.