Jenkins slackSend: channel alert notifications for @here or specific user

Viewed 1928

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.

2 Answers

Try it

def emailWithoutDomain = env.BUILD_USER_EMAIL.replaceAll("@.*","").trim()

slackSend ( message: 'I want to mention <@${emailWithoutDomain}> this @user as part of message', teamDomain: '', token: '', channel: '' )

Related