Azure Pipelines: Notification on Job failure

Viewed 5081

Is it possible to send a e-mail notification if a specific job fails within an azure pipeline?

Basically, i a testing stage in my pipeline where several jobs run in parallel which execute different test suites. Each test suite has a different guy who is responsible and must be notified if it fails.

I could only find notification options on failing the whole pipeline, but that's not what I want to do.

I also don't create any work items at the moment, and I couldn't find a "send-email-task" or something like this.

I could of course write my own script and execute it if a job fails, but I want to know if there is an easier way to solve my problem.

3 Answers

I don't think there is an out-of-the-box option like this, but you can use Send Email extension:

- task: SendEmail@1
  displayName: 'Send an email with subject Job A failed!'
  inputs:
    To: 'user@test.com'
    From: 'test@test.com'
    Subject: 'Job A failed!'
    SmtpServer: 'my smtp server'
  condition: failed()

Since there is no build-in way to do this, I decided to add a small Powershell script which simply executes after the VSTest task in my testing stage. Also thanks to the failed() condition, it will only execute if at least one test failed.

You can also write some external monitopring which will, verify status of your release throu REST API. I did something like this with proper azure function.

Related