JetBrains Space Help


Integration with Slack is quite a common task for a CI/CD system. For example, you may want to send build status messages to a Slack channel.

  1. Create a Slack application and install it to your Slack workspace. Note that to post messages to workspace channels, your application requires the chat:write permission.

  2. After you install the application, Slack will provide you its OAuth access token. You can also find this token in Slack on the application's OAuth & Permissions page. Save the token, for example, by copying it to the clipboard.

    Slack OAuth token
  3. In Space, create a secret (for example, slack-token) and specify the token as a secret's value.

  4. In the project's .space.kts file, add the code that will send messages to a particular channel. You can use the following snippet as a basis:

    @file:DependsOn("com.slack.api:slack-api-client:1.1.1") import com.slack.api.Slack job("send to slack") { container("openjdk:11") { env["TOKEN"] = Secrets("slack-token") kotlinScript { api -> val slack = Slack.getInstance() val token = System.getenv("TOKEN") val response = slack.methods(token).chatPostMessage { req ->"#automation").text("Hello from Space!") } println("$response") } } }

Last modified: 12 January 2021