[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class HarbormasterManagementBuildWorkflow 4 extends HarbormasterManagementWorkflow { 5 6 public function didConstruct() { 7 $this 8 ->setName('build') 9 ->setExamples('**build** [__options__] __buildable__ --plan __id__') 10 ->setSynopsis(pht('Run plan __id__ on __buildable__.')) 11 ->setArguments( 12 array( 13 array( 14 'name' => 'plan', 15 'param' => 'id', 16 'help' => pht('ID of build plan to run.'), 17 ), 18 array( 19 'name' => 'buildable', 20 'wildcard' => true, 21 ), 22 )); 23 } 24 25 public function execute(PhutilArgumentParser $args) { 26 $viewer = $this->getViewer(); 27 28 $names = $args->getArg('buildable'); 29 if (count($names) != 1) { 30 throw new PhutilArgumentUsageException( 31 pht('Specify exactly one buildable object, by object name.')); 32 } 33 34 $name = head($names); 35 36 $buildable = id(new PhabricatorObjectQuery()) 37 ->setViewer($viewer) 38 ->withNames($names) 39 ->executeOne(); 40 if (!$buildable) { 41 throw new PhutilArgumentUsageException( 42 pht('No such buildable "%s"!', $name)); 43 } 44 45 if (!($buildable instanceof HarbormasterBuildableInterface)) { 46 throw new PhutilArgumentUsageException( 47 pht('Object "%s" is not a buildable!', $name)); 48 } 49 50 $plan_id = $args->getArg('plan'); 51 if (!$plan_id) { 52 throw new PhutilArgumentUsageException( 53 pht('Use --plan to specify a build plan to run.')); 54 } 55 56 $plan = id(new HarbormasterBuildPlanQuery()) 57 ->setViewer($viewer) 58 ->withIDs(array($plan_id)) 59 ->executeOne(); 60 if (!$plan) { 61 throw new PhutilArgumentUsageException( 62 pht('Build plan "%s" does not exist.', $plan_id)); 63 } 64 65 $console = PhutilConsole::getConsole(); 66 67 $buildable = HarbormasterBuildable::initializeNewBuildable($viewer) 68 ->setIsManualBuildable(true) 69 ->setBuildablePHID($buildable->getHarbormasterBuildablePHID()) 70 ->setContainerPHID($buildable->getHarbormasterContainerPHID()) 71 ->save(); 72 73 $console->writeOut( 74 "%s\n", 75 pht( 76 'Applying plan %s to new buildable %s...', 77 $plan->getID(), 78 'B'.$buildable->getID())); 79 80 $console->writeOut( 81 "\n %s\n\n", 82 PhabricatorEnv::getProductionURI('/B'.$buildable->getID())); 83 84 PhabricatorWorker::setRunAllTasksInProcess(true); 85 $buildable->applyPlan($plan); 86 87 $console->writeOut("%s\n", pht('Done.')); 88 89 return 0; 90 } 91 92 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |