Page MenuHomeDevCentral

JenkinsPayloadAnalyzer.php
No OneTemporary

JenkinsPayloadAnalyzer.php

<?php
namespace Nasqueron\Notifications\Analyzers\Jenkins;
use Nasqueron\Notifications\Analyzers\BasePayloadAnalyzer;
class JenkinsPayloadAnalyzer extends BasePayloadAnalyzer {
/**
* The name of the service, used to get specific classes and config
*/
const SERVICE_NAME = "Jenkins";
///
/// Payload custom properties
///
/**
* Gets the name of the item, ie here of the job.
*
* @var string
*/
public function getItemName () {
return $this->payload->name;
}
///
/// Notify only on failure helper methods
///
/**
* Tries to get build status.
*
* @param out string $status
* @return bool indicates if the build status is defined in the payload
*/
private function tryGetBuildStatus (&$status) {
if (!isset($this->payload->build->status)) {
return false;
}
$status = $this->payload->build->status;
return true;
}
/**
* @return bool
*/
public function shouldNotifyOnlyOnFailure () {
return in_array(
$this->getItemName(),
$this->configuration->notifyOnlyOnFailure
);
}
/**
* Determines if the build status is a failure.
*
* @return bool
*/
public function isFailure () {
if (!$this->tryGetBuildStatus($status)) {
return false;
}
return $status === "FAILURE"
|| $status === "ABORTED"
|| $status === "UNSTABLE";
}
/**
* Indicates if we should handle this payload to trigger a notification.
*
* @return bool if false, this payload is to be ignored for notifications
*/
public function shouldNotify () {
return $this->isFailure() || !$this->shouldNotifyOnlyOnFailure();
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Feb 28, 20:13 (9 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2439016
Default Alt Text
JenkinsPayloadAnalyzer.php (1 KB)

Event Timeline