jenkinsci/discord-notifier-plugin

Feature Request: multiple channels

hedin-hiervard opened this issue · 8 comments

It's currently not possible to notify 2 channels and to add the plugin to the post-build step twice (it's greyed out). I think it's possible from a Pipeline, but I don't have a Pipeline job. Maybe as a workaround, someone could provide a simple downstream Pipeline job that only takes the upstream job info and sends it to Discord?

Jenkins doesn't allow to add post build action more than once, and it can't be changed.
I think that using pipeline is the only way to do this.

I think that using pipeline is the only way to do this.

Can you please help me to create a pipeline job that is run after the main job and the only thing it does - sends the messages to the several Discord channels with build summary and artifact links?

If you do not want to make pipeline jobs,

You could use the post-build action "Build other projects" to have it call downstream freestyle or multi-configuration projects that have the Discord notifier as post-build actions.

Hope this is helpful.

Thanks for the great work!

~ melt
getpimp.org | miner.farm

If you do not want to make pipeline jobs,

You could use the post-build action "Build other projects" to have it call downstream freestyle or multi-configuration projects that have the Discord notifier as post-build actions.

Yeah, but will it have access to the artifacts of the upstream project?

Ah, I didn't think of that. Still learning! :)

Sadly I can't help you with creating such pipeline as I don't know how to do it :/

If you do not want to make pipeline jobs,
You could use the post-build action "Build other projects" to have it call downstream freestyle or multi-configuration projects that have the Discord notifier as post-build actions.

Yeah, but will it have access to the artifacts of the upstream project?

You're right. I've explored a bit and it looks like you're going to need to do a pipeline for this one. The Journey into learning Groovy and making Pipelines stored in Github or other version control is a beautiful thing and makes life so much better. It's worth checking out.

Simply create a new pipeline and use the following snippet inside it. Note: I use the declarative pipeline syntax.

Here's a snippet with pipeline example for discordSend function:

node ('master') {
    stage ('Notify') {
def discordDesc = "Description here.."
(...)
discordSend description: discordDesc, 
                  footer: discordFooter, 
                  link: env.JOB_URL, 
                  result: currentBuild.currentResult, 
                  title: discordTitle, 
                  webhookURL: discordURL, 
                  successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'),
                  thumbnail: discordImage,
                  notes: "Here's some Notes! @<id_to_mention>"
   }
}

You can set the variables and then call discordSend however you like, or put the fields as inline strings.