add circleci job failure notifications for any jobs on master (#8393)

* add circleci job failure notifications for any jobs on master

* rename URL variable
This commit is contained in:
Alvin Huang 2020-07-28 14:54:48 -04:00 committed by GitHub
parent 15fd939fee
commit 3a7b9af518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 54 additions and 0 deletions

View File

@ -33,6 +33,33 @@ steps:
curl -sSL "${url}/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_amd64.tar.gz" | \ curl -sSL "${url}/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_amd64.tar.gz" | \
sudo tar -xz --overwrite -C /usr/local/bin gotestsum sudo tar -xz --overwrite -C /usr/local/bin gotestsum
# This step MUST be at the end of any set of steps due to the 'when' condition
notify-slack-failure: &notify-slack-failure
name: notify-slack-failure
when: on_fail
command: |
if [[ $CIRCLE_BRANCH == "master" ]]; then
CIRCLE_ENDPOINT="https://app.circleci.com/pipelines/github/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}?branch=${CIRCLE_BRANCH}"
GITHUB_ENDPOINT="https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/commit/${CIRCLE_SHA1}"
COMMIT_MESSAGE=$(git log -1 --pretty=%B | head -n1)
SHORT_REF=$(git rev-parse --short "${CIRCLE_SHA1}")
curl -X POST -H 'Content-type: application/json' \
--data \
"{ \
\"attachments\": [ \
{ \
\"fallback\": \"CircleCI job failed!\", \
\"text\": \"❌ Failed: \`${CIRCLE_USERNAME}\`'s <${CIRCLE_BUILD_URL}|${CIRCLE_STAGE}> job failed for commit <${GITHUB_ENDPOINT}|${SHORT_REF}> on \`${CIRCLE_BRANCH}\`!\n\n- <${COMMIT_MESSAGE}\", \
\"footer\": \"${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}\", \
\"ts\": \"$(date +%s)\", \
\"color\": \"danger\" \
} \
] \
}" "${FEED_CONSUL_GH_URL}"
else
echo "Not posting slack failure notifications for non-master branch"
fi
jobs: jobs:
# lint consul tests # lint consul tests
lint-consul-retry: lint-consul-retry:
@ -41,6 +68,7 @@ jobs:
steps: steps:
- checkout - checkout
- run: go get -u github.com/hashicorp/lint-consul-retry && lint-consul-retry - run: go get -u github.com/hashicorp/lint-consul-retry && lint-consul-retry
- run: *notify-slack-failure
# Runs Go linters # Runs Go linters
lint: lint:
@ -68,6 +96,7 @@ jobs:
name: lint sdk name: lint sdk
working_directory: sdk working_directory: sdk
command: *lintcmd command: *lintcmd
- run: *notify-slack-failure
# checks vendor directory is correct # checks vendor directory is correct
check-vendor: check-vendor:
@ -84,6 +113,7 @@ jobs:
echo "Git directory has vendor changes" echo "Git directory has vendor changes"
exit 1 exit 1
fi fi
- run: *notify-slack-failure
go-test: go-test:
docker: docker:
@ -134,6 +164,7 @@ jobs:
# The -C flag shouldn't be necessary, but it fails to find the commit # The -C flag shouldn't be necessary, but it fails to find the commit
# without it. # without it.
command: bash <(curl -s https://codecov.io/bash) -C "$CIRCLE_SHA1" command: bash <(curl -s https://codecov.io/bash) -C "$CIRCLE_SHA1"
- run: *notify-slack-failure
go-test-race: go-test-race:
docker: docker:
@ -171,6 +202,7 @@ jobs:
path: *TEST_RESULTS_DIR path: *TEST_RESULTS_DIR
- store_artifacts: - store_artifacts:
path: /tmp/jsonfile path: /tmp/jsonfile
- run: *notify-slack-failure
# split off a job for the API package since it is separate # split off a job for the API package since it is separate
go-test-api: go-test-api:
@ -206,6 +238,7 @@ jobs:
- store_artifacts: - store_artifacts:
path: /tmp/jsonfile path: /tmp/jsonfile
- run: *codecov_upload - run: *codecov_upload
- run: *notify-slack-failure
# split off a job for the SDK package since it is separate # split off a job for the SDK package since it is separate
go-test-sdk: go-test-sdk:
@ -238,6 +271,7 @@ jobs:
- store_artifacts: - store_artifacts:
path: *TEST_RESULTS_DIR path: *TEST_RESULTS_DIR
- run: *codecov_upload - run: *codecov_upload
- run: *notify-slack-failure
# build all distros # build all distros
build-distros: &build-distros build-distros: &build-distros
@ -252,6 +286,7 @@ jobs:
# save dev build to CircleCI # save dev build to CircleCI
- store_artifacts: - store_artifacts:
path: ./pkg/bin path: ./pkg/bin
- run: *notify-slack-failure
# build all 386 architecture supported OS binaries # build all 386 architecture supported OS binaries
build-386: build-386:
@ -299,6 +334,7 @@ jobs:
command: go build -o ./pkg/bin/linux_aarch64/consul -ldflags="-linkmode=external ${GOLDFLAGS}" command: go build -o ./pkg/bin/linux_aarch64/consul -ldflags="-linkmode=external ${GOLDFLAGS}"
- store_artifacts: - store_artifacts:
path: ./pkg/bin path: ./pkg/bin
- run: *notify-slack-failure
# create a development build # create a development build
dev-build: dev-build:
@ -318,6 +354,7 @@ jobs:
root: /go/bin root: /go/bin
paths: paths:
- consul - consul
- run: *notify-slack-failure
# upload development build to s3 # upload development build to s3
dev-upload-s3: dev-upload-s3:
@ -346,6 +383,7 @@ jobs:
echo "CircleCI - S3_ARTIFACT_PATH was not set" echo "CircleCI - S3_ARTIFACT_PATH was not set"
exit 1 exit 1
fi fi
- run: *notify-slack-failure
# upload dev docker image # upload dev docker image
dev-upload-docker: dev-upload-docker:
@ -360,6 +398,7 @@ jobs:
at: bin/ at: bin/
- setup_remote_docker - setup_remote_docker
- run: make ci.dev-docker - run: make ci.dev-docker
- run: *notify-slack-failure
# Nomad 0.8 builds on go0.10 # Nomad 0.8 builds on go0.10
# Run integration tests on nomad/v0.8.7 # Run integration tests on nomad/v0.8.7
@ -400,6 +439,7 @@ jobs:
path: *TEST_RESULTS_DIR path: *TEST_RESULTS_DIR
- store_artifacts: - store_artifacts:
path: *TEST_RESULTS_DIR path: *TEST_RESULTS_DIR
- run: *notify-slack-failure
# run integration tests on nomad/master # run integration tests on nomad/master
nomad-integration-master: nomad-integration-master:
@ -435,6 +475,7 @@ jobs:
docker login -u $WEBSITE_DOCKER_USER -p $WEBSITE_DOCKER_PASS docker login -u $WEBSITE_DOCKER_USER -p $WEBSITE_DOCKER_PASS
docker push hashicorp/consul-website docker push hashicorp/consul-website
fi fi
- run: *notify-slack-failure
algolia-index: algolia-index:
docker: docker:
@ -451,6 +492,7 @@ jobs:
cd website/ cd website/
npm install npm install
node scripts/index_search_content.js node scripts/index_search_content.js
- run: *notify-slack-failure
# build frontend yarn cache # build frontend yarn cache
frontend-cache: frontend-cache:
@ -471,6 +513,7 @@ jobs:
key: *YARN_CACHE_KEY key: *YARN_CACHE_KEY
paths: paths:
- ui-v2/node_modules - ui-v2/node_modules
- run: *notify-slack-failure
# build ember so frontend tests run faster # build ember so frontend tests run faster
ember-build-oss: &ember-build-oss ember-build-oss: &ember-build-oss
@ -490,6 +533,7 @@ jobs:
root: ui-v2 root: ui-v2
paths: paths:
- dist - dist
- run: *notify-slack-failure
# build ember so frontend tests run faster # build ember so frontend tests run faster
ember-build-ent: ember-build-ent:
@ -515,6 +559,7 @@ jobs:
root: ui-v2 root: ui-v2
paths: paths:
- dist - dist
- run: *notify-slack-failure
# build static-assets file # build static-assets file
build-static-assets: build-static-assets:
@ -531,6 +576,7 @@ jobs:
root: . root: .
paths: paths:
- ./agent/bindata_assetfs.go - ./agent/bindata_assetfs.go
- run: *notify-slack-failure
# run ember frontend tests # run ember frontend tests
ember-test-oss: ember-test-oss:
@ -552,6 +598,8 @@ jobs:
command: node_modules/.bin/ember exam --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` --path dist --silent -r xunit command: node_modules/.bin/ember exam --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` --path dist --silent -r xunit
- store_test_results: - store_test_results:
path: ui-v2/test-results path: ui-v2/test-results
- run: *notify-slack-failure
# run ember frontend tests # run ember frontend tests
ember-test-ent: ember-test-ent:
docker: docker:
@ -571,6 +619,8 @@ jobs:
command: node_modules/.bin/ember exam --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` --path dist --silent -r xunit command: node_modules/.bin/ember exam --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` --path dist --silent -r xunit
- store_test_results: - store_test_results:
path: ui-v2/test-results path: ui-v2/test-results
- run: *notify-slack-failure
# run ember frontend unit tests to produce coverage report # run ember frontend unit tests to produce coverage report
ember-coverage: ember-coverage:
docker: docker:
@ -588,6 +638,7 @@ jobs:
name: codecov ui upload name: codecov ui upload
working_directory: ui-v2 working_directory: ui-v2
command: bash <(curl -s https://codecov.io/bash) -v -c -C $CIRCLE_SHA1 -F ui command: bash <(curl -s https://codecov.io/bash) -v -c -C $CIRCLE_SHA1 -F ui
- run: *notify-slack-failure
envoy-integration-test-1.11.2: envoy-integration-test-1.11.2:
docker: docker:
@ -622,6 +673,7 @@ jobs:
path: *TEST_RESULTS_DIR path: *TEST_RESULTS_DIR
- store_artifacts: - store_artifacts:
path: *TEST_RESULTS_DIR path: *TEST_RESULTS_DIR
- run: *notify-slack-failure
envoy-integration-test-1.12.6: envoy-integration-test-1.12.6:
docker: docker:
@ -666,6 +718,7 @@ jobs:
make test-connect-ca-providers make test-connect-ca-providers
- store_test_results: - store_test_results:
path: *TEST_RESULTS_DIR path: *TEST_RESULTS_DIR
- run: *notify-slack-failure
# only runs on master: checks latest commit to see if the PR associated has a backport/* or docs* label to cherry-pick # only runs on master: checks latest commit to see if the PR associated has a backport/* or docs* label to cherry-pick
cherry-picker: cherry-picker:
@ -678,6 +731,7 @@ jobs:
fingerprints: fingerprints:
- "c9:04:b7:85:bf:0e:ce:93:5f:b8:0e:68:8e:16:f3:71" - "c9:04:b7:85:bf:0e:ce:93:5f:b8:0e:68:8e:16:f3:71"
- run: .circleci/scripts/cherry-picker.sh - run: .circleci/scripts/cherry-picker.sh
- run: *notify-slack-failure
workflows: workflows:
version: 2 version: 2