The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

Slack Notification Plugin

slackSend: Send Slack Message

Simple step for sending a Slack message to specified channel.
Use the advanced settings to override the Slack Plugin global configuration to include: token and channel.
Please see the Slack Plugin global configuration for more details on the fields. Usage Example:
slackSend "Build Started - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
  • attachments (optional)
    • Type: Object
  • baseUrl (optional)
    Allows overriding the Slack compatible app URL specified in the global configuration.
    • Type: String
  • blocks (optional)
    • Type: Object
  • botUser (optional)

    Bot user option indicates the token belongs to a custom Slack app bot user in Slack.

    If the notification will be sent to a user via direct message, the default integration sends it via @slackbot, use this option if you want to send messages via a bot user.

    • Type: boolean
  • channel (optional)
    Allows overriding the Slack Plugin channel specified in the global configuration. Multiple channels may be provided as a comma, semicolon, or space delimited string.
    slackSend channel: "#channel-name", message: "Build Started: ${env.JOB_NAME} ${env.BUILD_NUMBER}"
    • Type: String
  • color (optional)
    An optional value that can either be one of good, warning, danger, or any hex color code (eg. #439FE0). This value is used to color the border along the left side of the message attachment.
    slackSend color: "#439FE0", message: "Build Started: ${env.JOB_NAME} ${env.BUILD_NUMBER}"
    • Type: String
  • failOnError (optional)
    If set to true, then the step will abort the Workflow run if there is an error sending message.
    slackSend failOnError: true, message: "Build Started: ${env.JOB_NAME} ${env.BUILD_NUMBER}"
    • Type: boolean
  • iconEmoji (optional)

    Choose a custom emoji to use as the bot's icon in Slack, requires using a bot user

    • Type: String
  • message (optional)
    This is the main text in a message attachment, and can contain standard message markup. The content will automatically collapse if it contains 700+ characters or 5+ linebreaks, and will display a "Show more..." link to expand the content. Message may include global variables, for example environment and currentBuild variables:
    slackSend "started ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
    • Type: String
  • notifyCommitters (optional)

    Notify committers via direct message in addition to specified channels, requires using a bot user

    • Type: boolean
  • replyBroadcast (optional)
    • Type: boolean
  • sendAsText (optional)
    • Type: boolean
  • teamDomain (optional)
    Allows overriding the Slack Plugin Integration Team Domain specified in the global configuration.
    • Type: String
  • timestamp (optional)
    Allows updating an existing message instead of posting a new one.
    • Type: String
  • token (optional)
    Allows overriding the Slack Plugin Integration Token specified in the global configuration.
    • Type: String
  • tokenCredentialId (optional)

    The ID for the integration token from the Credentials plugin to be used to send notifications to Slack. The "Kind" of the credential must be "Secret text." If both "Integration Token" and "Integration Token Credential ID" are set, the "Integration Token Credential ID" will take precedence for security reasons.

    This overrides the global setting.

    • Type: String
  • username (optional)

    Choose a custom username to use as the bot's name, requires using a bot user

    • Type: String

slackUploadFile: Upload file to slack

  • filePath
    File path to search in to upload the file. Globs are accepted but only the first file found will be uploaded.
    slackUploadFile "file.txt"
    • Type: String
  • channel (optional)
    Allows overriding the Slack Plugin channel specified in the global configuration. Multiple channels may be provided as a comma separated string.
    slackUploadFile channel: "#channel-name", filePath: "file.txt"
    • Type: String
  • credentialId (optional)

    The ID for the bot user token from the Credentials plugin to be used to send notifications to Slack. The "Kind" of the credential must be "Secret text."

    This overrides the global setting.

    The user token must be the bot user oauth token
    • Type: String
  • initialComment (optional)
    A comment that will be added by the bot when the file is uploaded slackUploadFile initialComment: "Test result failures", filePath: "file.txt"
    • Type: String

slackUserIdFromEmail: Resolve Slack UserId from Email Address

  • email

    A Slack User ID will be resolved from the email address using the users.lookupByEmail API method. Requires using a bot user.

    • Type: String
  • botUser (optional)

    Bot user option indicates the token belongs to a custom Slack app bot user in Slack.

    If the notification will be sent to a user via direct message, the default integration sends it via @slackbot, use this option if you want to send messages via a bot user.

    • Type: boolean
  • tokenCredentialId (optional)

    The ID for the integration token from the Credentials plugin to be used to send notifications to Slack. The "Kind" of the credential must be "Secret text."

    This overrides the global setting.

    • Type: String

slackUserIdsFromCommitters: Resolve Slack UserIds from Changeset Authors

  • botUser (optional)

    Bot user option indicates the token belongs to a custom Slack app bot user in Slack.

    If the notification will be sent to a user via direct message, the default integration sends it via @slackbot, use this option if you want to send messages via a bot user.

    • Type: boolean
  • tokenCredentialId (optional)

    The ID for the integration token from the Credentials plugin to be used to send notifications to Slack. The "Kind" of the credential must be "Secret text."

    This overrides the global setting.

    • Type: String

Was this page helpful?

Please submit your feedback about this page through this quick form.

Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

    


See existing feedback here.