lambdacd.presentation.pipeline-state

This namespace contains functions useful to convert the internal state of a pipeline into something more easy to use for further processing, e.g. to present it to a user.

Functions taking a map step-id to step-result are usually called with the result of lambdacd.state.core/get-step-results

build-duration

(build-duration step-ids-and-results)

Takes a map of step-ids to step results and returns the duration of a build in seconds (excluding time the build spent waiting)

build-that-was-retriggered

(build-that-was-retriggered step-ids-and-results)

Takes a map of step-ids to step results and returns nil (for normal builds) or the build number of the build that was retriggered.

earliest-first-update

(earliest-first-update step-ids-and-results)

Takes a map of step-ids to step results and finds the earliest timestamp for :first-updated-at, usually the start time of a pipeline

history-for

(history-for all-state-or-ctx)

Returns a build history for a given ctx; Calling this with a complete build state (the get-all-result) is now DEPRECATED.

Example:

> (history-for ctx)
[{:build-number          8
  :status                :waiting
  :most-recent-update-at stop-time
  :first-updated-at      start-time
  :retriggered           nil
  :duration-in-sec       10
  :build-metadata {:some :metadata}}
 {:build-number          9
  :status                :running
  :most-recent-update-at stop-time
  :first-updated-at      start-time
  :retriggered           2
  :duration-in-sec       10
  :build-metadata {}}]

latest-most-recent-update

(latest-most-recent-update step-ids-and-results)

Takes a map of step-ids to step results and finds the latest timestamp for :most-recent-update-at, usually the end or most recent update of a pipeline

most-recent-step-result-with

(most-recent-step-result-with key ctx)

Searches the build history for the current build-step (as denoted by the :step-id in ctx) for a step result with a particular key and returns the complete step result.

not-retriggered?

deprecated in 0.13.1

(not-retriggered? result)

DEPRECATED

overall-build-status

(overall-build-status step-ids-and-results)

Takes a map of step-ids to step results and returns the status of the pipeline as a whole:

> (overall-build-status {'(0) {:status :success :most-recent-update-at stop-time :first-updated-at start-time}
                         '(1) {:status :running :most-recent-update-at stop-time :first-updated-at start-time}})
:running