KocproZ / jenkins-discord

A post-build plugin that sends the build status to a Discord channel.
MIT License
39 stars 36 forks source link

Support Jenkins Pipeline #13

Closed Dahlgren closed 7 years ago

Dahlgren commented 7 years ago
pipeline {
  agent any

  post {
    always {
      discordSend description: 'Jenkins Pipeline Build', footer: 'Footer Text', link: BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: JOB_NAME, webhookURL: 'Webhook URL'
    }
  }
}
jupjohn commented 7 years ago

Tell me why exactly you've made every field of the webhook editable? I'm confused. It also doesn't support the current features like disabling linking, enabling artifact lists etc...

Dahlgren commented 7 years ago

Pipeline steps are different from the usual Notifier plugins that are accessible post build. The discordSend can be invoked anytime during the build and multiple times.

Only webhookURL must be set, the rest is optional and can be omitted.

By allowing the Pipeline script to define the texts sent to Discord it's possible to send different messages for different stages in the pipeline. We use this to send notifications for each failing parallel build in our matrix pipeline. Once all parallel builds are completed we can also send a final notification for the entire pipeline in the post steps such as in the example in the dscription.

Some reasons for not using the other perform method,

By having this more open allows for more flexibility in pipeline usage. Most notification plugins such as slack works the same, see the example in it's repo https://github.com/jenkinsci/slack-plugin

I'm open for making changes in the PR, it doesn't have to be this way :)

jupjohn commented 7 years ago

Apart from those little things, if you could add a section in the README that explains how to use it that'd be great. I'll merge afterwards.

Dahlgren commented 7 years ago

I'll add some README documentation about how to use in Pipeline builds

Dahlgren commented 7 years ago

Please check if you want any further changes 😃

jupjohn commented 7 years ago

Thanks for the addition.