3

I'm trying to use Jenkins DSL with office-365-connector-plugin and restrict the notifications to master branch only.

From looking at the UI config in Jenkins it seems like this is acheivable using Macros: Connector Config

However I have no idea what to put there, moreover how can I use it in the DSL? I did see examples of people using it but I don't understand what they are acheiving (example)

Muji
  • 531
  • 6
  • 10

1 Answers1

1

Using a jenkinsfile, you could do it this way:

        stage('a stage') {
            when {
                branch 'master'
            }
            steps {
                office365ConnectorSend webhookUrl: 'https://outlook.office.com/webhook/d6cee...',
                    message: 'a message'
            }
        }

Or like this:

    post {
        failure {
            script {
                if (env.BRANCH_NAME == 'master') {
                    office365ConnectorSend webhookUrl: 'https://outlook.office.com/webhook/d6cee...',
                        message: 'a message'
                }
            }
        }
    }
Bertrand P
  • 820
  • 7
  • 24