Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Two bugfixes with environmental hooks.

  • Loading branch information...
commit 236a32c511b2d57f4cf65b57e58a9c8f963222f5 1 parent 6923dce
Wayne E. Seguin wayneeseguin authored
Showing with 18 additions and 11 deletions.
  1. +8 −2 README.md
  2. +7 −8 shell/functions
  3. +3 −1 shell/initialize
10 README.md
View
@@ -34,6 +34,13 @@ Each hook is the name of a step listed above prefixed with either before_ or
after_. For example around steps a - f there is a 'before_deploy' and an
'after_deploy'
+Hooks are only run if the hook file is executable, otherwise the file is
+considered disabled.
+
+Hooks are looked for and run from two places, shared then repository. First
+hooks are run from the shared_path/deploy/ directory and then from the
+shared_path/project_name/config/deploy/ directory.
+
If you want to execute a task before the code is moved in place but after
everything is setup in the staging area, use 'before_replace_current' hook.
@@ -45,10 +52,9 @@ If this is not the case please let me know right away and provide a gist of
## Prerequisites
-* git
+* git / subversion / mercurial (whichever the application's repository uses).
* curl
* rsync
-* subversion / mercurial (if the application's repository uses them).
## Resources
15 shell/functions
View
@@ -1,7 +1,6 @@
#!/bin/sh
set +o noclobber # Why yes, I did mean to clobber that file.
-typeset -g result
hook()
{
@@ -24,11 +23,11 @@ hook()
fi
# System, Environment specific
- if [[ -n "${environment}" ]] &&
- files are executable "$shared_path/deploy/#{$environment}/${_hook}"
+ if [[ -n "${environment:-}" ]] &&
+ files are executable "$shared_path/deploy/${environment}/${_hook}"
then
log step "${_hook} ( ${shared_path##${project_path}/}/deploy/${environment}/ )"
- hook_source "$shared_path/deploy/#{$environment}/${_hook}" &> >(tee -a "${deploy_log_path}/${_hook}.log")
+ hook_source "$shared_path/deploy/${environment}/${_hook}" &> >(tee -a "${deploy_log_path}/${_hook}.log")
log step success
fi
@@ -191,7 +190,7 @@ fail_release()
paths create "$discard_path" "$deploy_log_path"
# TODO: versionedfs last # switch to last version
- log step "Rolling back to previous release $previous"
+ log step "Reverting to previous release $previous"
paths move from "$previous" to "${release_path%/}"
log step success
}
@@ -315,6 +314,8 @@ cleanup()
do_deploy()
{
+ trace_filter "deploy" || set -o xtrace
+
# Logging (http://nakedape.cc/wiki/ShellHacks 1.6.1, 1.7, 1.11)
export log_file="${deploy_log_path}/deploy.log"
touch "${log_file}"
@@ -352,9 +353,7 @@ deploy()
typeset _step
for _step in "${deploy_steps[@]}"
do
- #step "${deploy_steps[@]}" >> "${deploy_log_path}/${_hook}" 2>&1
- step "${_step}" 2>>"${log_file}"
- #step "${_step}" >> "${deploy_log_path}/${_step}" 2>&1
+ step "${_step}" &> >(tee -a "${log_file}")
done
}
4 shell/initialize
View
@@ -1,7 +1,8 @@
#!/bin/sh
typeset -gx shared_path project_path stage_path release_path discard_path
-typeset -g previous_releases previous timestamp deploy_log_path _hooks_flag
+typeset -g previous_releases previous timestamp deploy_log_path _hooks_flag \
+ environment result
typeset -ga deploy_steps old_releases
if ! command exists rsync
@@ -20,6 +21,7 @@ versionedfs create \
timestamp="$(date +%m.%d.%YT%H:%M:%S)"
true \
+ ${environment:="development"} \
${discard_path:="${project_path}/discard"} \
${stage_path:="${project_path}/stage"} \
${release_path:="${project_path}/active/${project}"} \
Please sign in to comment.
Something went wrong with that request. Please try again.