/teamcity-slack

TeamCity Slack plugin

Primary LanguageScalaMIT LicenseMIT

TeamCity Slack plugin

Build Status

This plugin allows you to integrate your CI with Slack.

The main feature is that you can specify not exact branch name but the regexp branch mask.

For example you have separate build configurations for feature branches and common branches. Then it is easy to setup notifications into corresponding Slack channels.

The second big thing is that your can compose your own messages using template placeholders and Slack formatting.

And you can easily send notification without running the build with Try it feature.

Plugin automatically backups its settings after each modification.

Successful build Failed build Artifact links

Table of Contents

  1. Install plugin
  2. Build configuration
  3. Message placeholders
  4. Artifact links

Install plugin

Download from releases or compile sources with mvn package.

Next upload target/slackIntegration.zip to TeamCity data/plugins/ folder (restart is needed).

Go to api.slack.com

  • Create new app.
  • Go to Features - Incoming Webhooks and Activate Incoming Webhooks
  • Go to Bot Users - Add Bot User
  • Go to OAuth & Permissions and click Install App in Workspace
  • Now copy Bot User OAuth Access Token.

Paste this token into Administration -> Slack -> OAuth Access Token field.

Plugin setup

That's it! Now you can open any build configuration home and choose Slack tab.

By default personal notifications (private notifications) are disabled. Personal notifications notify only about failed builds.

Slack tab Only admins and projects admins have rights to access these settings.

Build configuration

Sample configuration:

Edit settings

Notifications for branches captured by regular expression will be sent to slack channel or/and private chat. Message will be compiled according to template.

The Only trigger when build changes options allows you to notify only when previous build status changed from failure to success or vice versa. The previous build is the latest build on the same branch as current build (or without branch if current has no branch), and its status is determined (failure or success) and it's not a personal build.

Note. Please avoid using heading # in channel name.

The build settings number is not limited, so you can set up notifications for feature branches in one channel, and for release branches in another one.

Message placeholders

{name}

Full name of the build configuration, has form "project_name :: buildconfig_name".

{number}

User defined build number.

{branch}

Branch display name, i.e. name to show to user. Unknown if not applicable.

Please make sure that your VCS settings are correct!

See TeamCity Docs and #21

{status}

succeeded if build successful, started if started, canceled if canceled, failed otherwise.

{link}

URL to view results page.

{mentions}

Slack users mentions only if build fails. Unknown users will be skipped.

{users}

TeamCity user name list only if build fails. Unknown users will be skipped.

{changes}

Concatenated description of head 5 changes from build with author name (from VCS) in square braces, e.g. My awesome feature [John Smith].

{reason}

Build problems that caused build failure when build is failed. Unknown if cannot detect.

{artifactLinks}

See Artifact links.

{allArtifactsDownloadUrl}

Link to download all artifacts as zip archive.

{artifactsRelUrl}

Artifacts relative path. It is necessary if you want to construct artifact link manually.

Parameters placeholders

You can also use project and build parameters, e.g. {%my.awesome.teamcity.param%}

Artifact links

In case you want to access build artifacts with third party web server (e.g. nginx) you can use this feature. Specify Public artifacts URL as root path served by your web server. And Artifacts mask in Build configuration. All other will be done automatically.

Sample nginx configuration:

location /art/ {
    alias <teamcity-data-dir>/system/artifacts/;
    autoindex on;
}