Reputation: 49
As a Developer,I need to send the notification to the user's Slack Channel (That channel has Jenkins CI app) from Jenkins dynamically.
So I have to get the below things of Jenkins CI app(Already installed in user's channel)by using Slack OAuth.
1.Team Subdomain
2.Integration Token
3.Base URL
I got the access token by using Slack API Documentation. But I don't have the clue to get those things by using access token in API Call. Can anyone help me out please?
Upvotes: 1
Views: 791
Reputation: 32737
If you only want to sent messages into a channel, you can simply use the incoming webhook that has already been installed for Jenkins.
Just take the existing URL and make a HTTP POST request to that URL like this:
POST https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Content-type: application/json
{
"text": "Hello, world."
}
The correct channel should already be pre-configured, but you can also specify your own by adding the channel
property to your request.
See the official documentation on more details on how to use incoming webhooks.
Upvotes: 1
Reputation: 1486
Let's go through each one:
Team Subdomain. Each Slack Workspace looks something like this: https://<teamname>.slack.com
where is used to access the Slack Workspace. So in order to access the workspace you need to know what it's subdomain is or in this case the <teamname>
The integration token and base url can be found in the webhook url from Jenkins. Your URL should look something like this: https://example.com/hooks/xxxx
. Where xxx is the Integration token and https://example.com/
is the base url
Upvotes: 0