Issue
Jenkins slackSend question: How to perform an alert notification to a channel that has received a message that needs to be addressed by either any member @here or a specific person ex @Jane.Doe?
Reviewed Jenkins Slack notifications: https://www.jenkins.io/doc/pipeline/steps/slack/
Tried adding @here to the beginning of slackSend message:
failure {
script {
slackSend(
color: "#FF0000",
channel: "${SLACK_CHANNEL}",
message: "@home FAILED"
)
}
}
However, adding @here to slackSend message does not initiate alert notification for that channel.
Suggestions?
Note: Received a comment from a coworker, I am investigating this path:
thought I remember needing to do a look up on users to get an ID and then some special syntax it parses into a username. been a while though.
Solution
First you must find the ID of the user and then mention it in the the message, like this example:
def userId = slackUserIdFromEmail('[email protected]')
slackSend(color: "good", message: "<@$userId> Message from Jenkins Pipeline")
Reference: https://plugins.jenkins.io/slack/
Edit:
If you want a put a special or a group mention, you only need follow the format guideline what can you see here : https://api.slack.com/reference/surfaces/formatting#special-mentions
Answered By - Enrique Tejeda
Answer Checked By - Mildred Charles (JavaFixing Admin)