3 final class HarbormasterPlanRunController
extends HarbormasterPlanController
{
5 public function handleRequest(AphrontRequest
$request) {
6 $viewer = $this->getViewer();
7 $plan_id = $request->getURIData('id');
9 $plan = id(new HarbormasterBuildPlanQuery())
11 ->withIDs(array($plan_id))
14 return new Aphront404Response();
17 $plan->assertHasRunCapability($viewer);
19 $cancel_uri = $this->getApplicationURI("plan/{$plan_id}/");
21 if (!$plan->canRunManually()) {
22 return $this->newDialog()
23 ->setTitle(pht('Can Not Run Plan'))
24 ->appendParagraph(pht('This plan can not be run manually.'))
25 ->addCancelButton($cancel_uri);
32 if ($request->isFormPost()) {
33 $buildable = HarbormasterBuildable
::initializeNewBuildable($viewer)
34 ->setIsManualBuildable(true);
36 $v_name = $request->getStr('buildablePHID');
39 $object = id(new PhabricatorObjectQuery())
41 ->withNames(array($v_name))
44 if ($object instanceof HarbormasterBuildableInterface
) {
46 ->setBuildablePHID($object->getHarbormasterBuildablePHID())
47 ->setContainerPHID($object->getHarbormasterContainerPHID());
49 $e_name = pht('Invalid');
50 $errors[] = pht('Enter the name of a revision or commit.');
53 $e_name = pht('Required');
54 $errors[] = pht('You must choose a revision or commit to build.');
60 $buildable->sendMessage(
62 HarbormasterMessageType
::BUILDABLE_BUILD
,
65 $buildable->applyPlan($plan, array(), $viewer->getPHID());
67 $buildable_uri = '/B'.$buildable->getID();
68 return id(new AphrontRedirectResponse())->setURI($buildable_uri);
73 $errors = id(new PHUIInfoView())->setErrors($errors);
76 $title = pht('Run Build Plan Manually');
77 $save_button = pht('Run Plan Manually');
79 $form = id(new PHUIFormLayoutView())
81 ->appendRemarkupInstructions(
83 "Enter the name of a commit or revision to run this plan on (for ".
84 "example, `rX123456` or `D123`).\n\n".
85 "For more detailed output, you can also run manual builds from ".
86 "the command line:\n\n".
87 " phabricator/ $ ./bin/harbormaster build <object> --plan %s",
90 id(new AphrontFormTextControl())
91 ->setLabel(pht('Buildable Name'))
92 ->setName('buildablePHID')
96 return $this->newDialog()
97 ->setWidth(AphrontDialogView
::WIDTH_FULL
)
100 ->addCancelButton($cancel_uri)
101 ->addSubmitButton($save_button);