Skip to content

Commit

Permalink
Merge pull request #57 from covermymeds/cje_post_deploy
Browse files Browse the repository at this point in the history
Add --post-deploy-script feature and minor bug fix
  • Loading branch information
kellycs authored Feb 4, 2019
2 parents 0f5727a + f5fd0ae commit ab28a5b
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 14 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 2019-02-1 Relase 1.4.3
### Summary
Bug Fix, added post deployment script execution

### Changes
- Fix issue when not in git checkoiut location using git plugin
- Added --post-deploy-script option to exec arbitrary script at end of run
- This passes `-d $dbname` and `-n $db_destination_name` to script passed in

## 2019-01-09 Relase 1.4.2
### Summary
Auto deploy folder bug fix
Expand Down
19 changes: 19 additions & 0 deletions dbdeployer
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ do
port_cli="-p ${port}"
shift
;;
--post-deploy-script)
shift
post_deploy_script="${1}"
shift
;;
-P|--password)
shift
password="${1}"
Expand Down Expand Up @@ -817,4 +822,18 @@ then
echo "One of the files did not deploy correctly. No files past that file have been deployed"
exit 1
fi

fi

if [ "${report}" != "true" ]
then
if ! [ -z "${post_deploy_script}" ]
then
exec_post_deploy_script "${post_deploy_script}"
fi
if [ $? -ne 0 ]
then
echo "The post deploy script failed to deploy."
exit 1
fi
fi
2 changes: 1 addition & 1 deletion dbdeployer_release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.4.2
version=1.5.1
24 changes: 24 additions & 0 deletions functions/exec_post_deploy_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
function exec_post_deploy_script() {

_script_to_exec="$1"

# database name will automatically be passed to script with -d flag

echo "Executing script post dbdeployer run: ${_script_to_exec} -d ${dbname} -n ${db_destination_name}"
script_result=`$_script_to_exec -d $dbname -n ${db_destination_name}`

if [ $? -ne 0 ]
then
echo "Failed to execute script: ${_script_to_exec}"
rc=1
else
rc=0
fi

echo -e $script_result

unset script_result
unset _script_to_exec
return $rc
}
29 changes: 16 additions & 13 deletions functions/usage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,48 @@ function usage() {
different machanism)
-m|--module-list Module or plugin directories to load. Should be a
comma seperated list. List module specified last
will be applied for functions that are redundant in
will be applied for functions that are redundant in
module list (example: git,report_override)
-n|--db-destination-name [name] Deploy a database (-d) to a specific destination db,
useful for when the source name does not match the
final name of the database to be created.
ex. determinator -> determinator_test
-o|--variables_to_replace '[key:value,key2:value]' This is a key/value pair where the
-o|--variables_to_replace '[key:value,key2:value]' This is a key/value pair where the
key and value are separated by a ':'. Multiple sets
can be specified by separating by comma's. If
can be specified by separating by comma's. If
variable-override is enabled this will use the 'sed'
command to find/replace values
command to find/replace values
-p|--port [port] Database port to connect on. (requires -s|server
to be specified)
--post-deploy-script [script] Can be a script name or command. This is run when
this variable is set and the script is not called
with the report flag.
-P|--password [password] Database password to use. (requires -U|username
to be specified)
-r|--report No argument, show report of what needs
-r|--report No argument, show report of what needs
deployed (requires -d to be specified)
-R|--change-control '[URL]' This will log a reference URL. Please include
-R|--change-control '[URL]' This will log a reference URL. Please include
single quotes around the URL. Field is restricted
to 255 characters. Recommended uses for this
to 255 characters. Recommended uses for this
option include link to version control or change
control ticket.
control ticket.
(if used with -r flag option is validated but ignored)
(if used with -u flag, will log for all deployed files)
(if used with -u flag, will log for all deployed files)
-s|--server [host/ip] Server name or IP address
-T|--dbtype [type] Database type defined from folders in:
${fn_basedir}/dbtype
-U|--username [username] Username to connect to the database as
-u|--update No argument, requires database to be specified
and will run all commands to bring a
database to current. Ultimately runs report
and will run all commands to bring a
database to current. Ultimately runs report
and executes findings
-v|--verbose No argument, shows what the variables are that
are being used at time of deployment
-x|--drop-database No argument, please note this is a desctructive change.
This will drop the database specified
This will drop the database specified
(requires -d|--database to be specified)
(not compatible with -r|report flag)
(not compatible with -k|skip flag)
(not compatible with -k|skip flag)
(cannot be used with deployment tracking database)
(can optionally include the -n|--db-destination-name)
-X|--drop-and-reload No argument, please note this is a destructive change.
Expand Down
4 changes: 4 additions & 0 deletions plugins/git/deployment_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ deployment_report() {
#standard deploy folders
echo "Running report for database: ${db_destination_name}"
IFS=':|' read -a folder_list <<< "${deployment_folders}"

#ensure we are in the directory where the checkout occurs since we will be using git
cd ${db_basedir}

for i in ${folder_list[@]}
do
echo "Differences for ${i}:"
Expand Down

0 comments on commit ab28a5b

Please sign in to comment.