No commit activity in last 3 years
No release in over 3 years
Sends deployment notifications based on deployments that occur on CircleCI.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 12.0
~> 3.0
~> 2.3

Runtime

~> 4.4
 Project Readme

Build Status Codacy Badge Codacy Coverage

CircleCI Deployment Notifier

Sends deployment notifications based on deployments that occur on CircleCI.

Deployment notifications on Slack

Deployment indications on New Relic

Assumptions:

  • Using CircleCI.
  • Using Github.
  • Using Slack for notifications and/or using New Relic.

You can also:

  • Deploy releases that are tagged using Github Releases.

Usage

Requires Ruby 2.0.0 or higher.

Add the following commands to your circle.yml deployment section:

gem install circleci_deployment_notifier
circleci_deployment_notify_slack -a "Application Name" -u "https://hooks.slack.com/services/WEBHOOK"
circleci_deployment_notify_new_relic -a "Application Name" --api-key "12345abcde" --app-id "12345678"

It's best to use environment variables for sensitive information such as Slack webhook URLs or API keys.

So here's an example circle.yml deployment section that assumes you've set the environment variables DEPLOYMENT_SLACK_WEBHOOK_URL and NEW_RELIC_API_KEY:

deployment:
  staging:
    branch: master
    commands:
    - # TODO: something to deploy the application to staging
    - gem install circleci_deployment_notifier
    - circleci_deployment_notify_slack -a "Application Staging" -u $DEPLOYMENT_SLACK_WEBHOOK_URL
    - circleci_deployment_notify_new_relic -a "Application Staging" --api-key $NEW_RELIC_API_KEY --app-id "12345678"
  production:
    tag: /v[0-9]+\.[0-9]+\.[0-9]+/
    owner: MyOrganization
    commands:
    - # TODO: something to deploy the application to production
    - gem install circleci_deployment_notifier
    - circleci_deployment_notify_slack -a "Application Production" -u $DEPLOYMENT_SLACK_WEBHOOK_URL
    - circleci_deployment_notify_new_relic -a "Application Production" --api-key $NEW_RELIC_API_KEY --app-id "87654321"

Tag Deploys

That production section is designed to build and deploy for tags like "v1.0.0" that are created in the fork of the repo that belongs to MyOrganization. (So tags created in forks do not cause a build or deployment.) See CircleCI docs for more info.

Slack Webhook

Create an Incoming Webhook service in Slack, and assign it the channel you want it to post. If you want to post staging and production notifications to different Slack channels, you will need to create different Webhooks for each.

New Relic

To get the New Relic App ID for each application, you must first have the application running and reporting to New Relic. This creates the application in New Relic and it will appear in the APM area of rpm.newrelic.com.

Find the application in New Relic, and get the App ID from its URL. The URL will look like https://rpm.newrelic.com/accounts/<your_account_number>/applications/<app_id>

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/RobinDaugherty/circleci_deployment_notifier.

FAQ

Why is this project built on Travis when it's specifically for CircleCI?

CircleCI does not support builds against multiple versions of Ruby, so for a tool like this, Travis is a better fit. This gem is for use by applications, where it will be built on a single version of Ruby and deployed to staging and/or production infrastructure owned by the team.

License

The gem is available as open source under the terms of the MIT License.