IF var ne value THEN
Runs the ops nested underneath it when one stash value does not match one piece
of text. It is IF var THEN with the answer flipped, and it shares that
op's form and every one of its limits: exact text, case sensitive, no ${var} expansion, one value
only.
The flip changes the failure mode. A variable that was never set does not equal anything, so this op runs its block for missing values as readily as for genuinely different ones.
Fields¶
Variable¶
The name of the stash value to read, on its own and with no ${} wrapper. Dots walk into nested
values (topic.title) and square brackets index a list (changesets[0].name). Bracket indexes can
be stacked, so changesets[0][1] reaches into a list of lists. A path that does not resolve gives
back nothing, and nothing is what triggers this op.
The field is a multi-line monospace box, not a single-line input. A stray newline or trailing space in it becomes part of the name, the lookup finds nothing, and the block runs for the wrong reason.
Value¶
Also a multi-line monospace box, and taller than the one above it. The text is compared literally
and never expanded, so ${project} typed here is ten characters. Nothing is trimmed, and a newline
you leave at the end counts as part of the value.
Leave Value blank and the op runs its block whenever the variable holds anything at all, including
the string 0. Leave both fields blank and the block never runs, because an empty variable name
resolves to nothing and nothing does not differ from blank.
Traps¶
The op is true for a missing variable. A rule that reads IF var ne value THEN job_type / static
runs its block on every job where nothing ever set job_type, including the ones where the loader
that was meant to set it failed silently. If you meant "set, and different", test for presence first
with a IF var condition THEN row using NOT EMPTY, and put
this op inside it.
Case and formatting count. PROD differs from prod, and 1.0 differs from 1, so both make the
block run. There is no case option and no numeric option on this op, so there is no way to turn that
off here.
When the variable holds a list or a hash, it differs from every piece of text you could type and the block always runs.
What it does at run time¶
The op appears in the job log as a step under whatever you named it, and it is one of the points at which a cancel request on the job is noticed. It writes nothing into the stash.
ELSE and ELSIF condition THEN attach to it normally. An ELSE under this op is the equality case, which reads as a double negative in the tree. Consider inverting the whole thing into IF var THEN with an ELSE instead.
On a Rollback pass the comparison is made again against the stash as it stands then, so the branch taken coming back can differ from the one taken going out.
Combining with other ops¶
IF var condition THEN covers this test with NOT EQUALS, and
adds the case and numeric options this op does not have. Use it whenever the value is not a fixed
code word.
For the "none of these" case, stack rows in that same op rather than chaining several of these. One
NOT IN row with a comma-separated list replaces a nest of three.
Examples¶
Skip the block for one job type and run it for every other, accepting that an unset job type counts as other.
Variable job_type
Value static
Run a block only when a flag exists and holds something.
Variable can_deploy
Value (blank)