lambdacd.stepsupport.chaining

Functions that allow you to use LambdaCDs pipeline mechanisms inside a step, i.e. chain several steps together:

(defn some-step [args ctx]
  (chaining args ctx
            (shell/bash injected-ctx "/ " "echo hello ")
            (shell/bash injected-ctx "/ " "echo world ")))

(defn some-step-with-error-handling [args ctx]
  (always-chaining args ctx
                   (run-tests injected-args injected-ctx)
                   (if (= :failure (:status injected-args))
                     (publish-test-failures injected-args injected-ctx))))

always-chain-steps

(always-chain-steps args ctx & steps)

Like chain-steps but does not stop after failure.

always-chaining

macro

(always-chaining args ctx & forms)

Like chaining but does not stop on failures. Status of the chain will be failure if one of the steps in the chain failed. Use last-step-status-wins to make the chain succeed even though a step in the chain failed.

chain-steps

(chain-steps args ctx & steps)

Takes a number of steps executes them as if they were part of the pipeline, i.e. will execute them one after the other, stop on failures and call the next step with the the results of the previous step as args. Think of this as an opinionated take on execute-steps so for full flexibility, use execute-steps directly.

Look at the chaining-macro for a more flexible syntax.

Example:

(chain-steps (some-args) (some-ctx)
             some-step
             some-other-step)

chaining

macro

(chaining args ctx & forms)

Syntactic sugar for chain-steps. Can work with arbitrary code and can inject args and ctx.

Example:

(chaining (some-args) (some-ctx)
          (some-step injected-args injected-ctx)
          (some-other-step injected-args injected-ctx))

injected-args

Placeholder for args for use in chaining and always-chaining

injected-ctx

Placeholder for ctx for use in chaining and always-chaining

last-step-status-wins

(last-step-status-wins step-result)

Takes a step result from chaining or execute-steps and replaces its status with the status of the last child. Often used together with always-chaining to be able to control the chains end-result after an element of the chain failed (see #122 for details).

Example:

(last-step-status-wins
  (always-chaining args ctx
                   (check-something injected-args injected-ctx)
                   (if (= :failure (:status injected-args))
                     (manualtrigger/wait-for-manual-trigger injected-args injected-ctx)
                     {:status :success})))