Skip to content

Commit

Permalink
Merge remote-tracking branch 'caarlos0/shippable'
Browse files Browse the repository at this point in the history
  • Loading branch information
espadrine committed Jun 6, 2015
2 parents 67e0549 + bfaa37a commit c6ac322
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,41 @@ cache(function(data, match, sendBadge, request) {
});
}));

// Shippable integration
camp.route(/^\/shippable?\/([^\/]+)(?:\/(.+))?\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var project = match[2]; // eg, 54d119db5ab6cc13528ab183
var branch = match[3];
var format = match[4];
var url = 'https://api.shippable.com/projects/' + project + '/badge';
if (branch != null) {
url += '?branchName=' + branch;
}
var badgeData = getBadgeData('build', data);
fetchFromSvg(request, url, function(err, res) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
badgeData.text[1] = res;
if (res === 'shippable') {
badgeData.colorscheme = 'brightgreen';
} else if (res === 'unshippable') {
badgeData.colorscheme = 'red';
} else {
badgeData.text[1] = res;
}
sendBadge(format, badgeData);

} catch(e) {
badgeData.text[1] = 'invalid';
sendBadge(format, badgeData);
}
});
}));

// Wercker integration
camp.route(/^\/wercker\/ci\/([a-fA-F0-9]+)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
Expand Down

0 comments on commit c6ac322

Please sign in to comment.