Skip to content

Commit

Permalink
Relocate the TeamCity code.
Browse files Browse the repository at this point in the history
To be with Travis, another build success checker.

Also, changed the comment so that it reflects that this is *not* a version
grabbing hook.
  • Loading branch information
espadrine committed May 21, 2014
1 parent 58adce8 commit 26b2eaa
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,35 @@ cache(function(data, match, sendBadge) {
});
}));

// TeamCity CodeBetter integration.
camp.route(/^\/teamcity\/codebetter\/(.*)\.(svg|png|gif|jpg)$/,
cache(function(data, match, sendBadge) {
var buildType = match[1]; // eg, `bt428`.
var format = match[2];
var apiUrl = 'http://teamcity.codebetter.com/app/rest/builds/buildType:(id:' + buildType + ')?guest=1';
var badgeData = getBadgeData('build', data);
request(apiUrl, { headers: { 'Accept': 'application/json' } }, function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
}
try {
var data = JSON.parse(buffer);
var status = data.status;
badgeData.text[1] = (status || '').toLowerCase();
if (status === 'SUCCESS') {
badgeData.colorscheme = 'brightgreen';
} else {
badgeData.colorscheme = 'red';
}
sendBadge(format, badgeData);
} catch(e) {
badgeData.text[1] = 'invalid';
sendBadge(format, badgeData);
}
});
}));

// Gittip integration.
camp.route(/^\/gittip\/(.*)\.(svg|png|gif|jpg)$/,
cache(function(data, match, sendBadge) {
Expand Down Expand Up @@ -954,35 +983,6 @@ cache(function(data, match, sendBadge) {
});
}));

// TeamCity CodeBetter version integration.
camp.route(/^\/teamcity\/codebetter\/(.*)\.(svg|png|gif|jpg)$/,
cache(function(data, match, sendBadge) {
var buildType = match[1]; // eg, `bt428`.
var format = match[2];
var apiUrl = 'http://teamcity.codebetter.com/app/rest/builds/buildType:(id:' + buildType + ')?guest=1';
var badgeData = getBadgeData('build', data);
request(apiUrl, { headers: { 'Accept': 'application/json' } }, function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
}
try {
var data = JSON.parse(buffer);
var status = data.status;
badgeData.text[1] = (status || '').toLowerCase();
if (status === 'SUCCESS') {
badgeData.colorscheme = 'brightgreen';
} else {
badgeData.colorscheme = 'red';
}
sendBadge(format, badgeData);
} catch(e) {
badgeData.text[1] = 'invalid';
sendBadge(format, badgeData);
}
});
}));

// Puppet Forge
camp.route(/^\/puppetforge\/v\/([^\/]+\/[^\/]+)\.(svg|png|gif|jpg)$/,
cache(function(data, match, sendBadge) {
Expand Down

0 comments on commit 26b2eaa

Please sign in to comment.