Run additional build tasks

Roman Parashchenko edited this page Oct 2, 2018 · 9 revisions

Run additional tasks like phoenix.digest or npm install when building

You can run additional tasks on the build host like phoenix.digest or npm install by adding pre- or posthooks to your edeliver config file (usually in .deliver/config) e.g. like that:

  # .deliver/config
  pre_erlang_clean_compile() {
    status "Running phoenix.digest" # log output prepended with "----->"
    __sync_remote " # runs the commands on the build host
      [ -f ~/.profile ] && source ~/.profile # load profile (optional)
      set -e # fail if any command fails (recommended)
      cd '$BUILD_AT' # enter the build directory on the build host (required)
      # prepare something
      mkdir -p priv/static # required by the phoenix.digest task
      # run your custom task
      APP='$APP' MIX_ENV='$TARGET_MIX_ENV' $MIX_CMD phoenix.digest $SILENCE
    "
  }

pre_erlang_clean_compile() will be invoked before the -----> Compiling sources step.

__sync_remote executes the commands on the build host.

[ -f ~/.profile ] && source ~/.profile and set -e are optional but edeliver default.

cd $BUILD_AT is required to enter the build directory.

$SILENCE redirects the output to /dev/null unless --verbose option is used.

After that any command can be invoked to execute additional build tasks, e.g. like phoenix.digest or npm install.

Other pre- / posthooks are:

Pre- / Post Hook Executed when
pre_init_app_remotely() before -----> Ensuring hosts are ready to accept git pushes
post_init_app_remotely() after -----> Ensuring hosts are ready to accept git pushes
pre_git_push() before -----> Pushing new commits with git to: host xy
post_git_push() after -----> Pushing new commits with git to: host xy
pre_erlang_get_and_update_deps() before -----> Fetching / Updating dependencies
post_erlang_get_and_update_deps() after -----> Fetching / Updating dependencies
pre_erlang_clean_compile() before -----> Compiling sources
post_erlang_clean_compile() after -----> Compiling sources
pre_relx_generate_relup() before -----> Generating relup to version xyz (upgrades only)
post_relx_generate_relup() after -----> Generating relup to version xyz (upgrades only)
pre_upgrade_release() before -----> Upgrading release to xyz (upgrades only)
post_upgrade_release() after -----> Upgrading release to xyz (upgrades only)
pre_erlang_generate_release() before -----> Generating release
post_erlang_generate_release() after -----> Generating release
pre_start_deployed_release() before -----> Starting deployed release
post_start_deployed_release() after -----> Starting deployed release
post_extract_release_archive() after -----> Extracting archive xyz

If you want to run your task also during development, use an exrm plugin.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.