Skip to content

Instantly share code, notes, and snippets.

@Holek
Created October 24, 2014 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Holek/db478dedd0e81c26f4b1 to your computer and use it in GitHub Desktop.
Save Holek/db478dedd0e81c26f4b1 to your computer and use it in GitHub Desktop.
Jenkins build categorization by month
  1. Open a project in Jenkins
  2. Click "more" in Build History (this should show all builds in that project)
  3. Open console, paste in above code.
  4. Inspect buildStats object.
var buildStats = {};
function buildChecker(buildRow) {
var linkText = Prototype.Selector.select('td:nth-child(2) a', buildRow);
var dateTxt = linkText && linkText.first() && (typeof linkText.first().text != 'undefined') && linkText.first().text.match(/([a-z]{3})-2014/i);
if (dateTxt) {
var date = dateTxt[1];
// console.log('date is', date);
var img = Prototype.Selector.select('td:first-child img', buildRow);
// console.log('img', img);
if (!buildStats[date]) buildStats[date] = {};
if (img.first() && img.first().alt != '') {
var state = (img.first().alt.match(/Success/) ? 'success' : 'failure');
if (buildStats[date][state]) {
// console.log('adding +1 to', date, state)
buildStats[date][state] += 1;
} else {
// console.log('adding +1 to', date, state)
buildStats[date][state] = 1;
}
}
}
}
$$("#buildHistory > tbody > tr").each(buildChecker);
buildStats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment