0

I had set-up notifications via Microsoft Teams for my jenkins job - success, failure, abort, etc.

pipeline {
  options {
    office365ConnectorWebhooks([[
                startNotification: true,
                notifySuccess: true,
                notifyFailure: true,
                notifyAborted: true,
                notifyBackToNormal: true,
                    url: 'webhook_url'
        ]]
    )
} }

With the help of above script i am receiving notifications for all except the failure notifications.

Even i aborted the job i am receiving the notification.

Can anyone help on this issue ?

Hariharan
  • 1
  • 1

1 Answers1

1

You can define a notification step regardless of the pipeline completion status using the post section and the always condition like the following:

pipeline {
    agent any
    stages {
        stage('Test notification') {
            steps {
                echo "Let's simulate a failure"
                error('Failing the build.')
            }
        }
    }
    post { 
        always { 
            echo 'I will always run!'
            office365ConnectorSend status: currentBuild.currentResult, webhookUrl: 'webhook_url'
        }
    }
}

Note that the syntax has changed. To learn more about the plugin usage:

Office 365 Connector plugin

Office 365 Connector steps

And about the Jenkins post usage: Jenkins Pipeline Syntax