Skip to content
This repository was archived by the owner on Jun 15, 2024. It is now read-only.

Step Support

Florian Sellmayr edited this page Mar 6, 2016 · 5 revisions

Overview

Import: (:require [lambdacd.steps.support :as support])

Contains support functionality to compose more complex build steps

Features

capture-output [ctx & body]

Macro that wraps the given body with *out* redirected to the output of the build step instead of stdout. Useful if you need your build steps to output text.

Example:

(defn some-build-step [args ctx]
  (capture-output ctx (println "Hello")
                      (println "World")
                      {:status :success}))
; Step Result: => {:out "Hello\nWorld\n" :status :success }

chain-steps [args ctx & steps]

Executes a number of build steps sequentially. Behaves as if those steps were part of a pipeline, i.e. data can be passed from one step to the other, stops after the first failure, ...

Useful if you want to combine several of your build steps into one more coarse-grained build step.

Example

(defn some-step [args ctx]
  (chain-steps args ctx some-other-step
                        some-third-step))

chaining [args ctx & forms]

Macro around chain-steps that allows defining chained steps inline.

(note bug #93 (fixed in versions >0.7.0))

Example:

(:require [lambdacd.steps.support :as support :refer [chaining injected-args injected-ctx])

(defn some-step [args ctx]
  (chaining args ctx (some-other-step injected-args injected-ctx)
                     (some-third-step injected-args injected-ctx)
                     (some-step-that-doesnt-need-parameters)
                     (some-step-with-parameters "param1" (:param2 injected-args) 42)))

; ---

(defn some-step-where-we-debug [args ctx]
  (capture-output ctx
             (chaining args ctx
                       (some-step injected-args injected-ctx)
                       (print "foo-value:" (:foo injected-args)) ; 
                       (some-other-step injected-args injected-ctx))))

Clone this wiki locally