Skip to content

Commit

Permalink
Try to improve messaging by removing the git text and slimming down t…
Browse files Browse the repository at this point in the history
…he slack message
  • Loading branch information
Chris Gilmer committed Jan 4, 2019
1 parent cd560d6 commit 14913bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -251,7 +251,6 @@ jobs:
- restore_cache:
keys:
- mymove-vendor-{{ checksum "Gopkg.lock" }}
- run: exit 1
- run:
name: Run make server_generate
command: make server_generate
Expand Down Expand Up @@ -407,6 +406,7 @@ jobs:
executor: mymove_small
steps:
- checkout
- run: exit 1
- restore_cache:
keys:
- go-pkg-dep-sources-{{ checksum "Gopkg.lock" }}
Expand Down
16 changes: 8 additions & 8 deletions bin/circleci-announce-broken-branch
@@ -1,19 +1,18 @@
#!/bin/bash
set -euo pipefail

# Get git diff from last commit and escape double quotes
GIT_TEXT=$(git --no-pager show --format=format:'%s' | sed 's/"/\\"/g')
NOW=$(date '+%s')
NOW_ISO8601=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

message="The $CIRCLE_PROJECT_REPONAME $CIRCLE_BRANCH branch broke on job $CIRCLE_JOB! Contact $CIRCLE_USERNAME for more information."
title="CircleCI $CIRCLE_BRANCH branch failure"
pretext="$CIRCLE_JOB #$CIRCLE_BUILD_NUM"
message="The $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME $CIRCLE_BRANCH branch broke on job $CIRCLE_JOB! Contact $CIRCLE_USERNAME for more information."

#####
## Announce in Slack channel
#####
# 'color' can be any hex code or the key words 'good', 'warning', or 'danger'
color="warning"
CIRCLE_JOB=deploy_fake_cgilmer
if [[ $CIRCLE_JOB == *"deploy"* ]]; then
color="danger"
fi
Expand All @@ -26,10 +25,11 @@ cat <<EOM
{
"fallback": "$message $CIRCLE_BUILD_URL",
"color": "$color",
"pretext": "$message",
"title": "CircleCI job $CIRCLE_JOB #$CIRCLE_BUILD_NUM",
"pretext": "$pretext",
"author_name": "$CIRCLE_USERNAME",
"title": "$title",
"title_link": "$CIRCLE_BUILD_URL",
"text": "$GIT_TEXT",
"text": "$message",
"ts": $NOW
}
]
Expand All @@ -54,7 +54,7 @@ cat <<EOM
"payload": {
"summary": "$message",
"timestamp": "$NOW_ISO8601",
"source": "CircleCI job $CIRCLE_JOB #$CIRCLE_BUILD_NUM",
"source": "$title for $pretext",
"severity": "info",
"class": "cicd failure"
},
Expand Down

0 comments on commit 14913bd

Please sign in to comment.