I wish to receive notification if the master branch fails in CircleCI.
There's a user request to add this feature, but it was closed without comment - so I don't know if Circle added the feature or didn't add it.
I can see there's filter in the Configuration Reference, but these seems only exist on the entire workflow - I'd like to filter just the notify part.
config.yml is included below.
version: 2.1
orbs:
node: circleci/node@4.0.0
slack: circleci/slack@4.0
executors:
docker-node-12:
docker:
- image: cimg/node:12.19
full-app:
resource_class: 2xlarge
docker:
- image: cimg/node:12.19
- image: elasticsearch:6.4.3
- image: circleci/postgres:10-ram
- image: circleci/redis:6
jobs:
install npm packages:
executor: docker-node-12
steps:
- checkout
- node/install-packages
- persist_to_workspace:
root: /home/circleci/project
paths:
- .
run tests:
description: Run App's tests
# https://circleci.com/docs/reference-2-1/#docker
parameters:
filter:
description: "Test filter for jest"
default: ""
type: string
executor: full-app
steps:
- attach_workspace:
at: /home/circleci/project
- run:
name: Run tests
command: |
cd /home/circleci/project; set -o allexport; cp .env.circleci .env; source .env
npx jest --passWithNoTests --runInBand --logHeapUsage << parameters.filter >>
notify:
docker:
- image: "cimg/base:stable"
steps:
- slack/notify:
custom: |
{
"blocks": [
{
"type": "section",
"fields": [
{
"type": "plain_text",
"text": "Oh no, master failed!",
"emoji": true
}
]
}
]
}
event: always
workflows:
install_and_test:
jobs:
- install npm packages
- run tests:
requires:
- install npm packages
matrix:
parameters:
filter:
- --testPathPattern='a'
- --testPathPattern='b'
- notify:
context: slack-secrets