jenkinsci / discord-notifier-plugin

A post-build plugin that sends the build status to a Discord channel.
https://plugins.jenkins.io/discord-notifier/
MIT License
50 stars 25 forks source link

Add **fields** #66

Open kimdwkimdw opened 2 years ago

kimdwkimdw commented 2 years ago

What feature do you want to see added?

Add additional fields arguments. Check below

https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html https://leovoel.github.io/embed-visualizer/

Upstream changes

No response

bestknighter commented 1 year ago

Can this also be exposed to Jenkins Scripting Pipeline?

EDIT: After reading the changelog of PR #92, I realized that there probably is an undocumented way. You can probably use like so:

discordSend([
  webhookURL: 'Your URL',
  fields: ["Key1:Value1", "Key2:Value2"]
])

Later this week I'll try and come back with my results.

EDIT: There is! I managed to get it working. All private fields of DiscordPipelineStep.java can be used as fields. And looking at the code, I realized that you just need to do the following:

discordSend([
  webhookURL: 'Your URL',
  fields: "Key1:Value1, Key2:Value2, Key 3:Value 3a; Value 3b"
])

To get it looking like:

Key1 Value1

Key2 Value2

Key3 Value3a; Value 3b

Sadly, there's no way to make them inline. At least not with how this was set up.