Skip to content

Commit 6354752

Browse files
committed
Release 0.0.1
1 parent 2e2f6c2 commit 6354752

File tree

3 files changed

+112
-19
lines changed

3 files changed

+112
-19
lines changed

README.md

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,79 @@
11
# Ember-cli-deploy-slack
22

3-
This README outlines the details of collaborating on this Ember addon.
3+
An ember-cli-deploy-plugin for sending deployment messages to [Slack](https://slack.com/).
44

5-
## Installation
5+
## Usage
66

7-
* `git clone` this repository
8-
* `npm install`
9-
* `bower install`
7+
This plugin will only work with the upcoming 0.5.0-release of
8+
[ember-cli-deploy](https://github.com/ember-cli/ember-cli-deploy). Right now
9+
you have to use my [didFail branch](levelbossmike/ember-cli-deploy#didFail-hook-).
1010

11-
## Running
11+
To setup ember-cli-deploy-slack you need to add a `slack`-entry into your
12+
`deploy.js` configuration file:
1213

13-
* `ember server`
14-
* Visit your app at http://localhost:4200.
14+
```js
15+
module.exports = function(environment) {
16+
var environments = {
17+
"development": {
18+
// ...
19+
"slack": {
20+
"webhookURL": "https://hooks.slack.com/services/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",
21+
"channel": "#notifications",
22+
"username": "ember-cli-deploy"
23+
},
24+
// ...
25+
},
1526

16-
## Running Tests
27+
"staging": {
28+
// ...
29+
},
1730

18-
* `ember test`
19-
* `ember test --server`
31+
"production": {
32+
// ...
33+
}
34+
};
2035

21-
## Building
36+
return environments[environment];
37+
};
38+
```
2239

23-
* `ember build`
40+
## Customization
2441

25-
For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
42+
`ember-cli-deploy-slack` will send default messages on the `didDeploy`- and
43+
`didFail`-hooks on the pipeline. Because every team is different and people
44+
tend to customize their automatic slack notifications messages can be
45+
customized.
46+
47+
To customize a message you simply add a function to your slack configuration
48+
options that is named the same as the hook notification you want to customize:
49+
50+
```js
51+
module.exports = function(environment) {
52+
var environments = {
53+
"development": {
54+
// ...
55+
"slack": {
56+
"webhookURL": "https://hooks.slack.com/services/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",
57+
"channel": "#notifications",
58+
"username": "ember-cli-deploy",
59+
"didDeploy": function(context, slack) {
60+
return slack.notify({
61+
text: 'w00t I can haz custumizations!'
62+
});
63+
}
64+
},
65+
// ...
66+
},
67+
```
68+
69+
70+
Notification hooks will be passed the deployment context and the slackNotifier
71+
utility class. The SlackNotifier uses [node-slackr](https://github.com/chenka/node-slackr) under the hood so you can use its `notify`-function accordingly. This enables you to customize your messages in any way possible. You can even add custom properties to the deployment context if that's what you need to do.
72+
73+
Please see the [Slack API documentation for message formatting](https://api.slack.com/docs/formatting)
74+
to see how you can customize your messages.
75+
76+
### Available hooks
77+
78+
`willDeploy`, `willBuild`, `build`, `didBuild`, `willActivate`, `activate`,
79+
`didActivate`, `didDeploy`, `didFail`

index.js

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ var yellow = chalk.yellow;
1212

1313
function applyDefaultConfigIfNecessary(config, prop, defaultConfig, ui){
1414
if (!config[prop]) {
15-
var value = defaultConfig[prop];
15+
var value = defaultConfig[prop] || function() { return; };
1616
config[prop] = value;
17-
ui.write(blue('| '));
18-
ui.writeLine(yellow('- Missing config: `' + prop + '`, using default: `' + value + '`'));
17+
if (defaultConfig[prop]) {
18+
ui.write(blue('| '));
19+
ui.writeLine(yellow('- Missing config: `' + prop + '`, using default: `' + value + '`'));
20+
}
1921
}
2022
}
2123

@@ -63,6 +65,42 @@ module.exports = {
6365
return executeSlackNotificationHook.bind(this)(context, 'willDeploy');
6466
},
6567

68+
willBuild: function(context) {
69+
return executeSlackNotificationHook.bind(this)(context, 'willBuild');
70+
},
71+
72+
build: function(context) {
73+
return executeSlackNotificationHook.bind(this)(context, 'build');
74+
},
75+
76+
didBuild: function(context) {
77+
return executeSlackNotificationHook.bind(this)(context, 'didBuild');
78+
},
79+
80+
willUpload: function(context) {
81+
return executeSlackNotificationHook.bind(this)(context, 'willUpload');
82+
},
83+
84+
upload: function(context) {
85+
return executeSlackNotificationHook.bind(this)(context, 'upload');
86+
},
87+
88+
didUpload: function(context) {
89+
return executeSlackNotificationHook.bind(this)(context, 'didUpload');
90+
},
91+
92+
willActivate: function(context) {
93+
return executeSlackNotificationHook.bind(this)(context, 'willActivate');
94+
},
95+
96+
activate: function(context) {
97+
return executeSlackNotificationHook.bind(this)(context, 'activate');
98+
},
99+
100+
didActivate: function(context) {
101+
return executeSlackNotificationHook.bind(this)(context, 'didActivate');
102+
},
103+
66104
didDeploy: function(context) {
67105
return executeSlackNotificationHook.bind(this)(context, 'didDeploy');
68106
},

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "ember-cli-deploy-slack",
3-
"version": "0.0.0",
4-
"description": "The default blueprint for ember-cli addons.",
3+
"version": "0.0.1",
4+
"description": "An ember-cli-deploy-plugin for sending messages to Slack",
55
"directories": {
66
"doc": "doc",
77
"test": "tests"
88
},
9+
"repository": "https://github.com/LevelbossMike/ember-cli-deploy-slack",
910
"scripts": {
1011
"start": "ember server",
1112
"build": "ember build",

0 commit comments

Comments
 (0)