Send Slack notifications to a specific slack channel

Answered

Hi All,

I am new to teamcity, but we are running Teamcity 2020.2.2 and I am attempting to get slack notifications setup to send our build notifications to a specific channel in slack.  I've been using the official slack notifications settings and I have it working so that it will send notifications directly to me, but I don't see how to send these to a specific channel.  Is there a way to do that with the official slack notifications?  If not, could someone point me to how to accomplish that?

0
4 comments
Avatar
Fedor Rumyantsev

Hello,

This is possible with the Notifications build feature, which is defined on specific build configurations; please see the Slack Notifier section for the details on configuration. It allows to send notifications either to a specific user or a channel. 

If you need to use the same channel for multiple build configurations, you could consider creating a build template with the Notifications feature, and then base your configurations on it. 
Please let me know if this helps.

0

Thanks for the info, Fedor.  I think I see how to do that.  Let me ask you this follow up question, we keep our settings in VCS and have the VCS setings read only, so to make changes we have to modify the kotlin dsl and push it to our default branch.  Is there some documentation on how to do that in Kotlin DSL?

Thanks Again.

0
Avatar
Fedor Rumyantsev

Hello!

Yes, the classes you would need to reference are defined in the auto-doc which you may reference at 

<TeamCity URL>/app/dsl-documentation

endpoint. Specifically, you would be looking for the:

1) /app/dsl-documentation/jetbrains.build-server.configs.kotlin.v2019_2.project-features/-slack-connection/index.html - see an example below:

features {
slackConnection {
id = "PROJECT_EXT_10"
displayName = "Slack"
botToken = "someToken"
clientId = "someId"
clientSecret = "someSecret"
}
}

and 2) /app/dsl-documentation/jetbrains.build-server.configs.kotlin.v2019_2.build-features/-notifications/index.html project feature:

    features {
notifications {
id = "BUILD_EXT_13"
notifierSettings = slackNotifier {
connection = "PROJECT_EXT_10"
sendTo = "someChannel"
messageFormat = simpleMessageFormat()
}
}
}

I hope this helps.

1

Thanks Fedor, that helps a lot, I think that's just what I'm looking for.

0

Please sign in to leave a comment.