Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4792510
JenkinsPayloadAnalyzer.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
JenkinsPayloadAnalyzer.php
View Options
<?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
Details
Attached
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)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment