Jenkins slackSend:@here 或特定用户的通道警报通知

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

Jenkins slackSend 问题:如何向已收到消息的频道执行警报通知,该消息需要任何成员 @here 或特定的人,例如 @Jane.Doe?

已查看 Jenkins Slack 通知:https://www.jenkins.io/doc/pipeline/steps/slack/

尝试将 @here 添加到 slackSend 消息的开头:

failure {
    script {
        slackSend(
            color: "#FF0000",
            channel: "${SLACK_CHANNEL}",
            message: "@home FAILED"
        )
    }
}

但是,将 @here 添加到 slackSend 消息不会启动该频道的警报通知。

建议?

注意:收到同事的评论,我正在调查这条路:

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.

首先你必须找到用户的ID,然后在消息中提及它,就像这个例子:

def userId = slackUserIdFromEmail('spengler@ghostbusters.example.com')
slackSend(color: "good", message: "<@$userId> Message from Jenkins Pipeline")

参考:https://plugins.jenkins.io/slack/

编辑:

如果您想要特别提及或集体提及,您只需遵循格式指南 what can you see here : https://api.slack.com/reference/surfaces/formatting#special-mentions