Filtering webhook notifications in 2.0

Hi all,

I’m migrating my company’s project from 1.0 to 2.0, and I’m hitting an issue with webhook filtering (i.e., only sending webhooks for certain branches).

In 1.0, the syntax to do this looked like this:

notify:
  webhooks:
    - url: https://foo.bar.com/build-webhook
experimental:
  notify:
    branches:
      only:
        - master
        - staging

However, in 2.0, that doesn’t seem to work. Does anyone have any advice how to filter when the webhook is sent?

Thanks so much!

This should still work in 2.0 - could you share your entire config?

@levlaz here ya go:

aliases:
  - &restore-yarn-cache
    restore_cache:
      name: Restoring cache 
      keys:
        - v1-dependencies-{{ checksum "package.json" }}
        # fallback to using the latest cache if no exact match is found
        - v1-dependencies-
  - &save-yarn-cache
    save_cache:
      name: Saving cache
      paths:
        - node_modules
      key: v1-dependencies-{{ checksum "package.json" }}
  - &install-yarn-dependencies
    run:
      name: Installing Yarn dependencies
      command: yarn install
  - &filter-only-master
    branches:
      only:
        - master
  - &filter-ignore-master
    branches:
      ignore:
        - master
  - &install-aws-cli
    run:
      name: Installing AWS CLI
      command: sudo apt-get update && sudo apt-get install -y awscli

defaults: &defaults
  docker:
    - image: circleci/node:8.11.1
  working_directory: ~/repo

version: 2
jobs:
  test:
    <<: *defaults
    steps:
      - checkout
      - *restore-yarn-cache
      - *install-yarn-dependencies
      - *save-yarn-cache
      - run: yarn run test
  deploy_staging:
    <<: *defaults
    steps:
      - checkout
      - *restore-yarn-cache
      - *install-yarn-dependencies
      - *save-yarn-cache
      - *install-aws-cli
      - run: yarn run deploy-staging
  deploy_master:
    <<: *defaults
    steps:
      - checkout
      - *restore-yarn-cache
      - *install-yarn-dependencies
      - *save-yarn-cache
      - *install-aws-cli
      - run: yarn run deploy-staging

notify:
  webhooks:
    - url: https://foo.bar.com/build-webhook
experimental:
  notify:
    branches:
      only:
        - master
        - staging

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - test
      - deploy_staging:
          requires:
            - test
          filters: *filter-ignore-master
      - deploy_master:
          requires:
            - test
          filters: *filter-only-master
1 Like

This should still work in 2.0

Sorry I forgot to mention that it works in 2.0 except for workflows.

Sadly, there are no workarounds that I am aware of.

Is this still the case? We’ve been making heavy use of workflows, and we need webhooks to truly commit to moving our CICD to circle.

Can you give any insight on where this feature is on the roadmap?

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.