Skip to content

Instantly share code, notes, and snippets.

Created May 23, 2012 10:32
Show Gist options
  • Select an option

  • Save anonymous/2774491 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/2774491 to your computer and use it in GitHub Desktop.
Build Profile Summary
function(doc) {
function toDateKey(timestamp) {
var d = new Date(timestamp);
var newdate = "";
var newdate2 = newdate.concat(d.getUTCDate(), "/", d.getUTCMonth() + 1, "/", d.getFullYear()," ",d.getUTCHours() + 1,":", d.getUTCMinutes() + 1,":", d.getUTCSeconds() + 1 );
return newdate2;
}
var event = null;
doc.events.some(function(evt) {
if (evt.eventType == "MavenExecutionRequest") {
event = evt;
return true;
}
return false;
});
if (doc.type == 'maven-build-profile')
{
var hostname = doc.headers.systemProperties['env.HOSTNAME'];
if (hostname == null) {
hostname = doc.headers.systemProperties['env.COMPUTERNAME'];
if (hostname == null) {
hostname = doc.headers.systemProperties['env.NODE_NAME'];
if (hostname == null) {
hostname = "undefined";
}
}
}
emit(doc._id, {'startdate': toDateKey(doc.headers.started),
'completeddate': toDateKey(doc.headers.completed),
'builduser': doc.headers.core.user,
'builduration': doc.headers.completed - doc.headers.started,
'baseDirectory': event.data.baseDirectory,
'pom': event.data.pom,
'workingDirectory': doc.headers.systemProperties['user.dir'],
'mavengoals': event.data.goals.join(', '),
'hostname': hostname,
'documentSize': JSON.stringify(doc).length
}); }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment