3 final class HarbormasterManagementUpdateWorkflow
4 extends HarbormasterManagementWorkflow
{
6 protected function didConstruct() {
9 ->setExamples('**update** [__options__] __buildable__')
10 ->setSynopsis(pht('Explicitly update the builds for __buildable__.'))
16 'help' => pht('Update only this build.'),
21 'Force the buildable to update even if no build status '.
22 'changes occur during normal update.'),
25 'name' => 'background',
27 'If updating generates tasks, queue them for the daemons '.
28 'instead of executing them in this process.'),
31 'name' => 'buildable',
37 public function execute(PhutilArgumentParser
$args) {
38 $viewer = $this->getViewer();
40 $force_update = $args->getArg('force');
42 $names = $args->getArg('buildable');
43 if (count($names) != 1) {
44 throw new PhutilArgumentUsageException(
45 pht('Specify exactly one buildable, by object name.'));
48 $buildable = id(new PhabricatorObjectQuery())
54 throw new PhutilArgumentUsageException(
55 pht('No such buildable "%s"!', head($names)));
58 if (!($buildable instanceof HarbormasterBuildable
)) {
59 throw new PhutilArgumentUsageException(
60 pht('Object "%s" is not a Harbormaster Buildable!', head($names)));
63 // Reload the buildable directly to get builds.
64 $buildable = id(new HarbormasterBuildableQuery())
66 ->withIDs(array($buildable->getID()))
70 $builds = $buildable->getBuilds();
71 $builds = mpull($builds, null, 'getID');
73 $build_id = $args->getArg('build');
75 $builds = array_select_keys($builds, array($build_id));
77 throw new PhutilArgumentUsageException(
79 'The specified buildable does not have a build with ID "%s".',
84 $console = PhutilConsole
::getConsole();
86 if (!$args->getArg('background')) {
87 PhabricatorWorker
::setRunAllTasksInProcess(true);
90 foreach ($builds as $build) {
94 'Updating build %d of buildable %s...',
96 $buildable->getMonogram()));
98 $engine = id(new HarbormasterBuildEngine())
103 $engine->setForceBuildableUpdate(true);
106 $engine->continueBuild();
109 $console->writeOut("%s\n", pht('Done.'));