Mate.Pipeline (Mate v0.1.5) View Source

This module keeps track of the build and deploy pipelines.

It will use the given steps from your Mate.Config to either build or deploy your application on the specified servers. The default steps will attempt to sniff whether or not you are in need of the assets pipeline, which uses npm by default.

The pipeline can be updated with custom steps using the configuration file .mate.exs, for example you can add a custom step module with the Mate.Pipeline.Step behaviour.

config :mate,
  steps: fn steps, pipeline ->
    pipeline.insert_before(steps, Mate.Step.CleanBuild, CustomStep)
  end,

  defmodule CustomStep do
    use Mate.Pipeline.Step

    @impl true
    def run(session) do
      IO.puts("Execute my custom code")
      {:ok, session}
    end
  end

You can also use useful commands like local_cmd/2, local_cmd/3, local_script/2, remote_cmd/2, remote_cmd/3, remote_script/2, copy_from/3 and copy_to/3 to interact with the local machine or with the build server in various ways.

Link to this section Summary

Functions

Returns list of default build steps.

Inserts a custom step in the given steps after a specific spec.

Inserts a custom step in the given steps before a specific spec.

Create a new Pipeline struct with default build steps

Create a new Pipeline struct with custom steps

Removes a specific step from the given steps.

Replaces a specific step with a custom step in the given steps

Runs all steps within a given session for the given context, using the driver from your configuration file. For build context it will use the build_server and for deploy context it will run on all deploy servers.

Run a specific step within the current session.

Link to this section Types

Specs

step() :: atom() | function()

Specs

steps() :: [step()]

Specs

t() :: %Mate.Pipeline{
  current_step: atom(),
  next_step: atom(),
  prev_step: atom(),
  steps: steps()
}

Link to this section Functions

Specs

default_steps() :: steps()

Returns list of default build steps.

Link to this function

insert_after(steps, target, new)

View Source

Specs

insert_after(steps :: steps(), target :: step(), new :: step()) :: steps()

Inserts a custom step in the given steps after a specific spec.

Example:

pipeline.insert_after(steps, Mate.Step.CleanBuild, CustomStep)
Link to this function

insert_before(steps, target, new)

View Source

Specs

insert_before(steps :: steps(), target :: step(), new :: step()) :: steps()

Inserts a custom step in the given steps before a specific spec.

Example:

pipeline.insert_before(steps, Mate.Step.CleanBuild, CustomStep)

Specs

new() :: t()

Create a new Pipeline struct with default build steps

Specs

new(steps :: steps()) :: t()

Create a new Pipeline struct with custom steps

Specs

remove(steps :: steps(), target :: step()) :: steps()

Removes a specific step from the given steps.

Example:

pipeline.remove(steps, Mate.Step.CleanBuild)
Link to this function

replace(steps, target, replacement)

View Source

Specs

replace(steps :: steps(), target :: step(), replacement :: step()) :: steps()

Replaces a specific step with a custom step in the given steps

Example:

pipeline.replace(steps, Mate.Step.CleanBuild, CustomStep)

Specs

run(session :: Mate.Session.t()) :: {:ok, Mate.Session.t()} | {:error, any()}

Runs all steps within a given session for the given context, using the driver from your configuration file. For build context it will use the build_server and for deploy context it will run on all deploy servers.

Specs

run_step(session :: Mate.Session.t(), step :: step()) :: Mate.Session.t()
run_step(steps :: steps(), sessions :: [Mate.Session.t()]) ::
  {:ok, Mate.Session.t()} | {:error, any()}

Run a specific step within the current session.