1

I'm trying to setup a Jenkins job to be able to take a slack channel name as a parameter, and then post messages, about who kicked off the build, and if it completed etc, how can my job get a slack token, for any given channel?

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
yash sathe
  • 11
  • 1

1 Answers1

0

No. This is not how tokens work with the Slack API. Tokens are always user based and for the whole workspace. So once you have a token you app can post to any public channel.

To get a token a user needs to install your Slack app. *)

Alternatively can create "dynamic" webhooks, that can post to any channel in a workspace. Check out this answer for details:

Creating a Slack Webhook programmatically

However, those are officialy legacy and might stop working some time in the future. So your safest approach would be to create a Slack app and install it to the workspace to get your token.

*) There once was a concept called "workspace tokens". You still find it in the documentation, but it never left the BETA stage and was canceled. Best to ignore it.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114