Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F81674427
HarbormasterTargetWorker.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Sep 7, 08:58
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Sep 9, 08:58 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
20606940
Attached To
rPH Phabricator
HarbormasterTargetWorker.php
View Options
<?php
/**
* Execute a build target.
*/
final
class
HarbormasterTargetWorker
extends
HarbormasterWorker
{
public
function
getRequiredLeaseTime
()
{
// This worker performs actual build work, which may involve a long wait
// on external systems.
return
60
*
60
*
24
;
}
private
function
loadBuildTarget
()
{
$data
=
$this
->
getTaskData
();
$id
=
idx
(
$data
,
'targetID'
);
$target
=
id
(
new
HarbormasterBuildTargetQuery
())
->
withIDs
(
array
(
$id
))
->
setViewer
(
$this
->
getViewer
())
->
executeOne
();
if
(!
$target
)
{
throw
new
PhabricatorWorkerPermanentFailureException
(
pht
(
'Bad build target ID "%d".'
,
$id
));
}
return
$target
;
}
public
function
doWork
()
{
$target
=
$this
->
loadBuildTarget
();
$build
=
$target
->
getBuild
();
$viewer
=
$this
->
getViewer
();
try
{
$implementation
=
$target
->
getImplementation
();
if
(!
$implementation
->
validateSettings
())
{
$target
->
setTargetStatus
(
HarbormasterBuildTarget
::
STATUS_FAILED
);
$target
->
save
();
}
else
{
$implementation
->
execute
(
$build
,
$target
);
$target
->
setTargetStatus
(
HarbormasterBuildTarget
::
STATUS_PASSED
);
$target
->
save
();
}
}
catch
(
Exception
$ex
)
{
$target
->
setTargetStatus
(
HarbormasterBuildTarget
::
STATUS_FAILED
);
$target
->
save
();
}
id
(
new
HarbormasterBuildEngine
())
->
setViewer
(
$viewer
)
->
setBuild
(
$build
)
->
continueBuild
();
}
}
Event Timeline
Log In to Comment