kuleuven / jenkins-mattermost-plugin

Jenkins plugin for Mattermost
MIT License
24 stars 46 forks source link

Custom message on each task #5

Closed egavard closed 4 years ago

egavard commented 8 years ago

Hi,

I'd like to know if it is possible, for each notification kind, to set a custom message. I'd like, for example, on a broken build notify concerned users with @ markup.

Thanks

jovandeginste commented 8 years ago

Would that mean those users are always the same for a given job? (ie. fixed per-job configuration in jenkins?)

egavard commented 8 years ago

I mean that, for example, on a broken build, I'd like to advise the product owner and the scrum master that there's a problem. Otherwise, on a simply unstable build, I'd like to only advise developers.

I would customize each message with the corrects @ to target concerned users in the jenkins conf.

jovandeginste commented 7 years ago

This issue has been open for a while now, and I've been thinking about it ever since. The reason I've not made any implementation for this is the following.

Since a few months I'm using Jenkinsfiles. This lets me combine any (supported) plugins programmatically. This means I can send any Mattermost notification at any stage of the job, exactly the way I want it (as a user).

If you never heard of Jenkinsfiles or the Jenkins workflow/pipelines plugins, I honestly suggest you check it out!

If there is anything holding you back from using it, I'm sorry this solution is not what you need. It may be opportune to reevaluate?

zdtsw commented 7 years ago

We have similar requirement from our projects: when a build fails, mattermost sends direct message to the one who either starts the job or pushes the code changes, or at least use @ to mark them on the channel. We do not have problem to send notification at any stage in the job by using Jenkins 2.0 pipeline. But we want to target users, more than just broadcast the "failed job status" to the whole channel.

jovandeginste commented 7 years ago

@zdtsw if you add @username in the message, the user is "targeted"; at this time it's not possible to send a direct message to a user via Mattermost.

zdtsw commented 7 years ago

@jovandeginste , I'v it before posted here, but it did not work.....

e.g: in my Jenkinsfile, mattermostSend channel: "#team1", color: 'bad', message: " @wezh01 job failed: ${JOB_URL}${BUILD_NUMBER} "

Go to mattermost #team1 channel, I can see: @wezh01 job failed: http://myjenkins.com/job/whatmattermost/51 but @wezh01 is just a plain text, and I did not get any notification.

jovandeginste commented 7 years ago

I understand; probably because it is sent+formatted as "attachement" under the hood. That is a useful feature/setting to implement.

charlietsai commented 7 years ago

I know this is old but I recently needed to use user-mentions as well. The above PR adds text as an optional argument for mattermostSend that adds that to the text field, which does allow for searchable and highlightable text.

jovandeginste commented 7 years ago

This should be solved with v2.4.1 if you use Jenkins Pipelines