-
Notifications
You must be signed in to change notification settings - Fork 0
/
normalizer_travisci.js
32 lines (27 loc) · 1018 Bytes
/
normalizer_travisci.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var Travisci_Normalizer = function() {};
Travisci_Normalizer.prototype.icon = 'https://blog.travis-ci.com/images/travis-mascot-200px.png';
Travisci_Normalizer.prototype.normalize = function(options, callback) {
var payload = options.payload;
if (!payload) {
return callback("No payload sent");
}
var normalized = this._standard_normalize(payload);
normalized.glipguid = options.glipguid;
return callback(null, normalized);
};
Travisci_Normalizer.prototype._standard_normalize = function(payload) {
return {
icon: this.icon,
name: "Travis CI",
link: payload.compare_url,
body: this._get_markdown(payload),
payload: payload
};
}
Travisci_Normalizer.prototype._get_markdown = function(payload) {
var mkdn = 'Build [#' + payload.number + '](' + payload.build_url
+ ') ([' + payload.commit.substr(0,7) + '](' + payload.compare_url + ')) of '
+ payload.repository.name + '@' + payload.branch;
return mkdn;
}
module.exports.Travisci_Normalizer = Travisci_Normalizer;