How can I trigger a notification only when a branch is merged?

burke livingston's Avatar

burke livingston

18 Mar, 2019 07:50 AM

I have a notification configured only to fire for a certain branch, however it seems that pull requests against that branch also trigger the notification. Is it possible to only send the notification when the pull request is merged?

Config Excerpt:

branches: only: - development

notifications: - provider: Slack incoming_webhook: on_build_success: true on_build_failure: false template: >- {{#jobs}} {{#artifacts}} <{{url}}|Build {{buildVersion}}> {{/artifacts}} {{/jobs}}

    &lt;{{buildUrl}}|Appveyor&gt; &lt;{{commitUrl}}|Github&gt;</code>

  1. Support Staff 1 Posted by Ilya Finkelshte... on 18 Mar, 2019 07:27 PM

    Ilya Finkelshteyn's Avatar

    Hi Burke,

    We have no option to filter notification by PR. But what you can do is instead of built-in notification write a simple script based on slack REST API (sample) and run it only if APPVEYOR_PULL_REQUEST_TITLE environment variable is not set AND APPVEYOR_REPO_BRANCH is development. Run it on_finish

    Something like this:

    - ps: if ((-not $env:APPVEYOR_PULL_REQUEST_TITLE) -and ($env:APPVEYOR_REPO_BRANCH -eq "development")) {.\notifySlack.ps1}

    For Slack notification script you can also use environment variables. And sure use secure variable for Slack token.


  2. 2 Posted by burke livingsto... on 19 Mar, 2019 07:14 AM

    burke livingston's Avatar

    Hi Ilya,
    This was very helpful. Thank you for your quick reply.

    • Burke
  3. Ilya Finkelshteyn closed this discussion on 19 Mar, 2019 04:59 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac