Circleci Slack



  1. Circleci Slack-secrets
  2. Circleci Slack App
  3. Circleci Slack Integration
  4. Circleci Slack
Circleci SlackCircleci SlackCircleci
  • A bot command preparenext is triggered on Slack. It sends a message to Google App Engine (GAE). It sends a message to Google App Engine (GAE). Then GAE parses the message and makes a request with needed parameters to CircleCI using pipeline.
  • CircleCI’s Slack orb can be used to provide other types of notifications, including notifying a slack channel of a pending approval or sending a status alert at the end of a job based on success or failure. For more information and to view usage examples, see the CircleCI Slack orb page. Using the IRC Orb.

My fellow engineers are very productive, so code is always being pushed and deployed. We use CircleCI and its GitHub integration to manage our continuous deployment process. CircleCI, via a Slack webhook, posts every successful and failed build into our #build channel.

Circleci Slack-secrets

@gmemstr @KateCatlin. How should a notification work if you can’t define a when: on a job?I.e. A property with which you can run a job after one or more previous jobs finished even if they failed. It’s only possible to add when: always (or onfail) on a step (see configuration reference). If you can only add a notify step, you couldn’t simply use any job from any orb.

But I don’t need to know about every successful and failed build. I want the #build channel to only ping me for my successful and failed builds. Actually, only the failed builds. (I really care about those!) Unfortunately, CircleCI’s Slack integration can’t help: it knows who wrote the commit, but it doesn’t know who they are on Slack. It makes sense why this doesn’t exist out of the box; how would CircleCI learn such a mapping? Where would it be stored? Even if CircleCI provided some sort of lookup method, what if it still needed to be tailored to how my team handles build notifications?

Enter Transposit.

My CircleCI Router app acts as a bridge between CircleCI and Slack. It replaces the GitHub username in the message sent from CircleCI with the corresponding Slack ID. Engineers who have authenticated with my app can mute the #build channel and only get notified for their own builds, for which the message will @mention them.

Circleci Slack App

Here’s how it works #

Circleci Slack Integration

My teammates sign in with Slack and add their GitHub credentials. They can choose notifications for all builds or only for failures, via Transposit’s user settings.

Next, I replaced CircleCI’s Slack Webhook URL with my own, created in Transposit.

When CircleCI hits the webhook, my operation pulls the GitHub username from the message (it’s always the second word) and replaces it with the user’s Slack ID. I’ve created the mapping between identifiers using the application stash, which is a built-in k/v store. Depending on the state of the build (and that user’s preferences) we’ll @ them in the #build channel using the Slack connector.

Slack

Everything is wrapped in a try/catch so the original message will always be sent if there was an error in the code.

Success:

Fork my app to customize your team’s build notifications!

Circleci Slack

Orb

Get insights from Transposit in your inbox monthly.