Skip to content

Instantly share code, notes, and snippets.

@paulresdat
Last active April 26, 2018 17:57
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 paulresdat/4a990c7bfb0cc940ebb493a83b0bb4f2 to your computer and use it in GitHub Desktop.
Save paulresdat/4a990c7bfb0cc940ebb493a83b0bb4f2 to your computer and use it in GitHub Desktop.
ALVIN on jenkins: automates building when random unit test failures keep happening on a branch
(function($) {
var timeSet = 0;
var count = 0;
var log = false;
function check()
{
setTimeout(function() {
timeSet = 10000;
var title = $('img', $('a', $('table'))).attr('title');
if (title == 'Success > Console Output') {
logMessage('Success! Finally!');
logMessage(new Date(Date.now()).toLocaleString());
}
else if (title == 'In progress > Console Output') {
count++;
if (count == 10) {
logMessage('... in progress ... still checking ...');
count = 0;
}
check();
}
else {
logMessage("'" + title + "'" + ' FOUND : calling build');
$('#side-panel > div > div.task').each(function() {
if (/Build Now/.test($(this).html())) {
var html = $(this).html();
var func = html.replace(/.*?(build_id\d+).*/m, '$1');
eval(func + '($("a", $(this))[0]);');
logMessage('called ' + func + '($("a", $(this))[0]);');
logMessage(new Date(Date.now()).toLocaleString());
check();
}
});
}
}, timeSet);
}
function logMessage(message)
{
if (log) {
console.log(message);
}
}
check();
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment