public function execute(HarbormasterBuild $build, HarbormasterBuildTarget $build_target) { $viewer = PhabricatorUser::getOmnipotentUser(); $settings = $this->getSettings(); $variables = $build_target->getVariables(); $artifact = $build_target->loadArtifact($settings['artifact']); $impl = $artifact->getArtifactImplementation(); $lease = $impl->loadArtifactLease($viewer); // TODO: Require active lease. $command = $this->mergeVariables('vcsprintf', $settings['command'], $variables); $interface = $lease->getInterface(DrydockCommandInterface::INTERFACE_TYPE); $exec_future = $interface->getExecFuture('%C', $command); $harbor_future = id(new HarbormasterExecFuture())->setFuture($exec_future)->setLogs($build_target->newLog('remote', 'stdout'), $build_target->newLog('remote', 'stderr')); $this->resolveFutures($build, $build_target, array($harbor_future)); list($err) = $harbor_future->resolve(); if ($err) { throw new HarbormasterBuildFailureException(); } }
protected function logHTTPResponse(HarbormasterBuild $build, HarbormasterBuildTarget $build_target, BaseHTTPFuture $future, $label) { list($status, $body, $headers) = $future->resolve(); $header_lines = array(); // TODO: We don't currently preserve the entire "HTTP" response header, but // should. Once we do, reproduce it here faithfully. $status_code = $status->getStatusCode(); $header_lines[] = "HTTP {$status_code}"; foreach ($headers as $header) { list($head, $tail) = $header; $header_lines[] = "{$head}: {$tail}"; } $header_lines = implode("\n", $header_lines); $build_target->newLog($label, 'http.head')->append($header_lines); $build_target->newLog($label, 'http.body')->append($body); }