Giter VIP home page Giter VIP logo

tcslacknotifierplugin's Introduction

TCSlackNotifierPlugin - TeamCity -> Slack Notifications

A plugin for TeamCity to post notifications to slack

It works by registering as a server listener, and posts to slack on build events like successful builds (optionally also builds starting and failing)

#Build Plugin

Gradle is used to build. Wrapper is included in the project so you dont need to install it, just have java.

./gradlew buildZip

this will generate a zip file with the right meta data in the right folder structure at : build/distributions/TCSlackNotifierPlugin-<version>.zip

#Install Plugin

Copy the zip file into TeamCity plugin directory inside the data directory, usually .BuildServer

scp build/distributions/TCSlackNotifierPlugin-<version>.zip buildserver:.BuildServer/plugins/slackNotifier.zip

Then restart TeamCity.

#Configuration

###In slack Add a new webhook integration. Make a note of the Token.

###In TeamCity

Edit the main config file, usually .BuildServer/config/main-config.xml and add an element like so:

<server rootURL="http://localhost:8111">
  ...
  <slackNotifier postSuccessful="true" postFailed="false" postStarted="false" >
    <slackWebToken>testToken2</slackWebToken>
    <slackDefaultChannel>#general</slackDefaultChannel>
    <slackPostUrl>https://tapadoo.slack.com/services/hooks/incoming-webhook?token=</slackPostUrl>
    <slackLogoUrl>http://build.tapadoo.com/img/icons/TeamCity32.png</slackLogoUrl>
  </slackNotifier>
  ...
  ...

You can set the attributes on slackNotifier element (postSuccessful,postFailed,postStarted) to decide that notifications you would like posted.

Replace the web token with the token from slack. Change the postUrl also to point to the right slack team. The url can be found in the webhook integraton page, just remove the token from the end. Change the logo url whatever you want.

This by default will post all builds to slack. you can tweak these on a project level though

####Project Config (Optional)

To change channel or disable per project:

Edit the plugin specific xml config, plugin-settings.xml probably somewhere inside .BuildServer/config/projects/PROJECTNAME

<settings>
  <slackSettings enabled="true">
    <channel>#blah</channel>
  </slackSettings>
</settings>

#Note on TeamCity version support

I'm still using TeamCity 7.1 , but a few tests on the free version of TeamCity 8 went fine, and it seems to work there also.

###Issues

  • all xml config - needs web ui extensions for updating settings from GUI. Considering it.
  • channel can be changed per-project either by environmental variable (SLACK_CHANNEL) or by changing the project specific xml in the data directory. This could also use web ui extension UI for editing.
  • All or nothing notifications. By default, all builds are posted. It can be disabled per project, but not currently by build config.

License

MIT License.

tcslacknotifierplugin's People

Contributors

jasonconnery avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.