Slack
Posts a message to Slack. You must provide either a bot or a personal token with the following scopes set:
-
channels:join
-
chat:write
-
chat:write.public
-
Log into the target Slack workspace.
-
Create a Slack app.
-
Click on Incoming Webhooks.
-
Create a new webhook.
-
Copy the generated webhook URL.
-
Webhooks are not protected, anyone with access to the webhook URI can send messages to the target room. Prefer
setting the JRELEASER_SLACK_WEBHOOK environment variable over explicitly setting a value in the configuration DSL.
|
Configuration
Legend:
-
required
-
optional
-
may use environment variable
-
accepts Name Templates
#
announce:
#
slack:
# Enables or disables Slack.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `NEVER`.
#
active: ALWAYS
# Defines the connection timeout in seconds.
# Defaults to `20`.
#
connectTimeout: 20
# Defines the read timeout in seconds.
# Defaults to `60`.
#
readTimeout: 60
# Additional properties used when evaluating templates.
#
extraProperties:
# Key will be capitalized and prefixed with `slack`, i.e, `slackFoo`.
foo: bar
# The ApiKey associated with the given account.
#
token: __USE_ENVIRONMENT_VARIABLE__
# The webhook associated with a specific Slack channel.
#
webhook: __USE_ENVIRONMENT_VARIABLE__
# The channel where the message will be sent to
# Defaults to `#announce`.
#
channel: '#announce'
# The announcement message.
# Review the available Name Templates.
#
message: '🚀 {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}'
# Path to a template file that contains the message.
# Review the available Name Templates.
# Defaults to `src/jreleaser/templates/slack.tpl`.
#
messageTemplate: path/to/template/slack.tpl
#
[announce.slack]
# Enables or disables Slack.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `NEVER`.
#
active = "ALWAYS"
# Defines the connection timeout in seconds.
# Defaults to `20`.
#
connectTimeout = 20
# Defines the read timeout in seconds.
# Defaults to `60`.
#
readTimeout = 60
# Additional properties used when evaluating templates.
#
extraProperties.foo = "bar"
# Key will be capitalized and prefixed with `slack`, i.e, `slackFoo`.
# The ApiKey associated with the given account.
#
token = "__USE_ENVIRONMENT_VARIABLE__"
# The webhook associated with a specific Slack channel.
#
webhook = "__USE_ENVIRONMENT_VARIABLE__"
# The channel where the message will be sent to
# Defaults to `#announce`.
#
channel = "#announce"
# The announcement message.
# Review the available Name Templates.
#
message = "🚀 {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}"
# Path to a template file that contains the message.
# Review the available Name Templates.
# Defaults to `src/jreleaser/templates/slack.tpl`.
#
messageTemplate = "path/to/template/slack.tpl"
{
//
"announce": {
//
"slack": {
// Enables or disables Slack.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `NEVER`.
//
"active": "ALWAYS",
// Defines the connection timeout in seconds.
// Defaults to `20`.
//
"connectTimeout": 20,
// Defines the read timeout in seconds.
// Defaults to `60`.
//
"readTimeout": 60,
// Additional properties used when evaluating templates.
//
"extraProperties": {
// Key will be capitalized and prefixed with `slack`, i.e, `slackFoo`.
"foo": "bar"
},
// The ApiKey associated with the given account.
//
"token": "__USE_ENVIRONMENT_VARIABLE__",
// The webhook associated with a specific Slack channel.
//
"webhook": "__USE_ENVIRONMENT_VARIABLE__",
// The channel where the message will be sent to
// Defaults to `#announce`.
//
"channel": "#announce",
// The announcement message.
// Review the available Name Templates.
//
"message": "🚀 {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}",
// Path to a template file that contains the message.
// Review the available Name Templates.
// Defaults to `src/jreleaser/templates/slack.tpl`.
//
"messageTemplate": "path/to/template/slack.tpl"
}
}
}
<jreleaser>
<!--
-->
<announce>
<!--
-->
<slack>
<!--
Enables or disables Slack.
Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
Defaults to `NEVER`.
-->
<active>ALWAYS</active>
<!--
Defines the connection timeout in seconds.
Defaults to `20`.
-->
<connectTimeout>20</connectTimeout>
<!--
Defines the read timeout in seconds.
Defaults to `60`.
-->
<readTimeout>60</readTimeout>
<!--
Additional properties used when evaluating templates.
-->
<extraProperties>
<!--
Key will be capitalized and prefixed with `slack`, i.e, `slackFoo`.
-->
<foo>bar</foo>
</extraProperties>
<!--
The ApiKey associated with the given account.
-->
<token>__USE_ENVIRONMENT_VARIABLE__</token>
<!--
The webhook associated with a specific Slack channel.
-->
<webhook>__USE_ENVIRONMENT_VARIABLE__</webhook>
<!--
The channel where the message will be sent to
Defaults to `#announce`.
-->
<channel>#announce</channel>
<!--
The announcement message.
Review the available Name Templates.
-->
<message>🚀 {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}</message>
<!--
Path to a template file that contains the message.
Review the available Name Templates.
Defaults to `src/jreleaser/templates/slack.tpl`.
-->
<messageTemplate>path/to/template/slack.tpl</messageTemplate>
</slack>
</announce>
</jreleaser>
jreleaser {
//
announce {
//
slack {
// Enables or disables Slack.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `NEVER`.
//
active = 'ALWAYS'
// Defines the connection timeout in seconds.
// Defaults to `20`.
//
connectTimeout = 20
// Defines the read timeout in seconds.
// Defaults to `60`.
//
readTimeout = 60
// Additional properties used when evaluating templates.
// Key will be capitalized and prefixed with `slack`, i.e, `slackFoo`.
//
extraProperties.put('foo', 'bar')
// The ApiKey associated with the given account.
//
token = '__USE_ENVIRONMENT_VARIABLE__'
// The webhook associated with a specific Slack channel.
//
webhook = '__USE_ENVIRONMENT_VARIABLE__'
// The channel where the message will be sent to
// Defaults to `#announce`.
//
channel = '#announce'
// The announcement message.
// Review the available Name Templates.
//
message = '🚀 {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}'
// Path to a template file that contains the message.
// Review the available Name Templates.
// Defaults to `src/jreleaser/templates/slack.tpl`.
//
messageTemplate = 'path/to/template/slack.tpl'
}
}
}
You may define either message
or messageTemplate
, with the former taking precedence over the latter.
Environment
When not explicitly set, the value of the following properties may be resolved from an environment variable or a system property as shown in the table. The system property takes precedence over the environment variable.
System Property | Environment Variable |
---|---|
active |
|
jreleaser.announce.slack.active |
JRELEASER_ANNOUNCE_SLACK_ACTIVE |
token |
|
jreleaser.announce.slack.token |
JRELEASER_ANNOUNCE_SLACK_TOKEN |
webhook |
|
jreleaser.announce.slack.webhook |
JRELEASER_ANNOUNCE_SLACK_WEBHOOK |