Skip to content

Commit d07ebbd

Browse files
committed
Adding support to enable/disable live status output which may be useful
in consoles that do not support this output making the log file more useful.
1 parent 069db43 commit d07ebbd

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ Environment variables are used to control the deployment actions. A brief summar
133133
| `AWS_CODE_DEPLOY_S3_SSE` | No | If specified and `true` will ensure the CodeDeploy archive is stored in S3 with Server Side Encryption (SSE) |
134134
| `AWS_CODE_DEPLOY_REVISION_DESCRIPTION` | No | A description that is stored within AWS Code Deploy that stores information about the specific revision |
135135
| `AWS_CODE_DEPLOY_DEPLOYMENT_DESCRIPTION` | No | A description that is stored within AWS Code Deploy that stores information about the specific deployment |
136+
| `AWS_CODE_DEPLOY_OUTPUT_STATUS_LIVE` | No | Boolean [true|false] that specifies whether the deployment status should use a single line showing live status. In CI environments where the "\r" is not supported, set this to false for better logging. Default = true |
136137

137138

138139
## Examples

bin/aws-code-deploy.sh

+14-5
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,22 @@ note "You can follow your deployment at: https://console.aws.amazon.com/codedepl
489489
# see documentation http://docs.aws.amazon.com/cli/latest/reference/deploy/create-deployment.html
490490
# ----------------------
491491
DEPLOYMENT_OVERVIEW=${AWS_CODE_DEPLOY_DEPLOYMENT_OVERVIEW:-true}
492-
if [ "true" = "$DEPLOYMENT_OVERVIEW" ]; then
492+
if [ "true" == "$DEPLOYMENT_OVERVIEW" ]; then
493493
h1 "Deployment Overview"
494494

495495
DEPLOYMENT_GET="aws deploy get-deployment --output json --deployment-id \"$DEPLOYMENT_ID\""
496496
h2 "Monitoring deployment \"$DEPLOYMENT_ID\" for \"$APPLICATION_NAME\" on deployment group $DEPLOYMENT_GROUP ..."
497497
info "$DEPLOYMENT_GET"
498-
printf "\n"
498+
499+
# If the environment supports live reloading use carriage returns for a single line.
500+
if [ "true" == "${AWS_CODE_DEPLOY_OUTPUT_STATUS_LIVE}" ]; then
501+
status_opts="\r${bold}"
502+
status_opts_live="\r${bold}${blink}"
503+
printf "\n"
504+
else
505+
status_opts="\n${bold}"
506+
status_opts_live="\n${bold}"
507+
fi
499508

500509
while :
501510
do
@@ -523,11 +532,11 @@ if [ "true" = "$DEPLOYMENT_OVERVIEW" ]; then
523532
STATUS=$(echo "$DEPLOYMENT_GET_OUTPUT" | jsonValue "status" | tr -d "\r\n" | tr -d " ")
524533
ERROR_MESSAGE=$(echo "$DEPLOYMENT_GET_OUTPUT" | jsonValue "message")
525534

526-
printf "\r${bold}${blink}Status${reset} | In Progress: $IN_PROGRESS | Pending: $PENDING | Skipped: $SKIPPED | Succeeded: $SUCCEEDED | Failed: $FAILED | "
535+
printf "${status_opts_live}Status${reset} | In Progress: $IN_PROGRESS | Pending: $PENDING | Skipped: $SKIPPED | Succeeded: $SUCCEEDED | Failed: $FAILED | "
527536

528537
# Print Failed Details
529538
if [ "$STATUS" == "Failed" ]; then
530-
printf "\r${bold}Status${reset} | In Progress: $IN_PROGRESS | Pending: $PENDING | Skipped: $SKIPPED | Succeeded: $SUCCEEDED | Failed: $FAILED |\n"
539+
printf "${status_opts}Status${reset} | In Progress: $IN_PROGRESS | Pending: $PENDING | Skipped: $SKIPPED | Succeeded: $SUCCEEDED | Failed: $FAILED | \n\n"
531540
error "Deployment failed: $ERROR_MESSAGE"
532541

533542
# Retrieve failed instances. Use text output here to easier retrieve array. Output format:
@@ -619,7 +628,7 @@ if [ "true" = "$DEPLOYMENT_OVERVIEW" ]; then
619628

620629
# Deployment succeeded
621630
if [ "$STATUS" == "Succeeded" ]; then
622-
printf "\r${bold}Status${reset} | In Progress: $IN_PROGRESS | Pending: $PENDING | Skipped: $SKIPPED | Succeeded: $SUCCEEDED | Failed: $FAILED |\n"
631+
printf "${status_opts}Status${reset} | In Progress: $IN_PROGRESS | Pending: $PENDING | Skipped: $SKIPPED | Succeeded: $SUCCEEDED | Failed: $FAILED | \n\n"
623632
success "Deployment of application \"$APPLICATION_NAME\" on deployment group \"$DEPLOYMENT_GROUP\" succeeded"
624633
break
625634
fi

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aws-code-deploy",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Bash script to easily deploy applications with AWS Code Deploy.",
55
"author": "TechPivot",
66
"main": "bin/aws-code-deploy.sh",

0 commit comments

Comments
 (0)