Send a notification during a conditional

I’d like to be able to send a notification that a conditional is waiting for a response to Slack, and maybe even have the conditional display inside of Slack or have some way to trigger the option to continue from the notification message.

Hiya @vtkatzke, welcome to the Buildkite Forum!

Am I right in thinking that you’re wanting to be notified when there’s a blocked step requiring a response in order to continue a build?

If so, you should be able to set up a conditional notification in Slack with something like:

notify:
  - slack: "#general"
    if: build.state == "blocked"

You can take a look at our docs for conditional notifications here: https://buildkite.com/docs/pipelines/notifications#conditional-notifications

I hope that helps, please sing out if you have further questions.

Hey, Shevaun! Yes, partially. I can set that up, although I’m not quite sure if that can be part of the block step or if it needs to be part of a separate notify section. It’s pretty difficult to tell from the documentation when to use which style and format. And frankly, the flexibility of the notify functionality leaves a lot to be desired, and there’s feature requests all over the forum to make it broader.

The next part of it is that instead of clicking through to the buildkite console and advancing the build, I want to be able to trigger the continuation from a button in Slack by sending a custom notification JSON string in the appropriate block format.

What I’d taken doing in command steps was to call out to a shell script that will hit our slack webhook with a JSON formatted string that allows me to customize the message. Is that possible with the existing yaml notify functionality?

Hey @vtkatzke!

Sorry you ran into trouble with the docs, we’ll have a review of that page and see if we can clear things up! The notify block sits at the same level as the steps block, like in this example from the Notifications docs page Shevaun linked:

steps:
  - command: "tests.sh"
  - wait
  - command: "build.sh"

notify:
  - email: "dev@acmeinc.com"

Do you have more than one block step in your pipeline? If you’ve only got the one, then Shevaun’s example using the if conditional will check if that block step needs unblocking and send a message if it does. If you’ve got multiple and only want to alert on one of them, that gets a bit trickier :thinking:

You can totally do a custom message with the slack notify attribute! There’s an attribute called message that will let you set what you need:

notify:
  - slack: "#general"
      message: "Hello I'm a custom message"

As far as being able to click a button to do the unblocking, that sounds like a cool feature! I’ll keep a note of it and see if there’s interest from other customers we’re chatting to. In the meantime, what do you think about a workaround using our API? The REST API has an unblock endpoint that you can hit to unblock a job without having to go into the API. There’s some more info about that endpoint on the Jobs API docs page :blush:

can notify have two condition

notify:
  - slack: "#general"
      message: "Hello I'm a custom success message"
    if: build.state == "passed"
  - slack: "#general"
      message: "Hello I'm a custom failed message"
    if: build.state == "failed"