function printRecentlyBrokenOrBackToSuccessBuildOutputText($view, \JenkinsApi\Jenkins $jenkins, $channel, $outputString, $previousRun, $hipchat) { foreach ($view->allJobs as $job) { $color = ""; if ($job->buildable == true) { echo "Checking job : " . $job->name . " with color: " . $job->color . "\n"; if (strcmp($job->color, "red") == 0) { $succeededJob = $jenkins->getJob($job->name); if (hasColorChangedSinceLastRun($succeededJob, $previousRun)) { if ($succeededJob->builds[0]->timestamp / 1000 < strtotime($channel['alerttimestring'])) { $color = "red"; $outputString .= "<a target=\"_blank\" href = \"" . $job->url . "\">" . $job->name . "</a> has failed to build. \n"; } } } else { if (strcmp($job->color, "blue") == 0) { $succeededJob = $jenkins->getJob($job->name); if (hasColorChangedSinceLastRun($succeededJob, $previousRun)) { if ($succeededJob->builds[0]->timestamp / 1000 < strtotime($channel['alerttimestring'])) { $color = "green"; $outputString .= "<a target=\"_blank\" href = \"" . $job->url . "\">" . $job->name . "</a> back to successful build\n"; } } } } } else { echo "Skipping unbuildable: " . $job->name . "\n"; } if (strlen($outputString) > 0) { $outputString = getGreeting() . "\n" . $outputString; $hipchat->postOutputWithColor($outputString, $color); $outputString = ""; } } }
function getBrokenBuildOutputText($view, \JenkinsApi\Jenkins $jenkins, $channel, $outputString) { foreach ($view->jobs as $job) { if ($job->buildable == true) { if (strcmp($job->color, "red") == 0) { $failedJob = $jenkins->getJob($job->name); if ($failedJob->builds[0]->timestamp / 1000 < strtotime($channel['alerttimestring'])) { $outputString .= "<a href=\"" . $job->url . "\">" . $job->name . "</a> appears to have been broken since " . getPrettyDateFromTimestamp($failedJob->builds[0]->timestamp / 1000) . " " . "\n"; } } } } return $outputString; }