3 final class HarbormasterUploadArtifactBuildStepImplementation
4 extends HarbormasterBuildStepImplementation
{
6 public function getName() {
7 return pht('Upload File');
10 public function getGenericDescription() {
11 return pht('Upload a file.');
14 public function getBuildStepGroupKey() {
15 return HarbormasterPrototypeBuildStepGroup
::GROUPKEY
;
18 public function getDescription() {
21 $this->formatSettingForDescription('path'),
22 $this->formatSettingForDescription('hostartifact'));
25 public function execute(
26 HarbormasterBuild
$build,
27 HarbormasterBuildTarget
$build_target) {
28 $viewer = PhabricatorUser
::getOmnipotentUser();
30 $settings = $this->getSettings();
31 $variables = $build_target->getVariables();
33 $path = $this->mergeVariables(
38 $artifact = $build_target->loadArtifact($settings['hostartifact']);
39 $impl = $artifact->getArtifactImplementation();
40 $lease = $impl->loadArtifactLease($viewer);
42 $interface = $lease->getInterface('filesystem');
44 // TODO: Handle exceptions.
45 $file = $interface->saveFile($path, $settings['name']);
47 // Insert the artifact record.
48 $artifact = $build_target->createArtifact(
51 HarbormasterFileArtifact
::ARTIFACTCONST
,
53 'filePHID' => $file->getPHID(),
57 public function getArtifactInputs() {
60 'name' => pht('Upload From Host'),
61 'key' => $this->getSetting('hostartifact'),
62 'type' => HarbormasterHostArtifact
::ARTIFACTCONST
,
67 public function getArtifactOutputs() {
70 'name' => pht('Uploaded File'),
71 'key' => $this->getSetting('name'),
72 'type' => HarbormasterHostArtifact
::ARTIFACTCONST
,
77 public function getFieldSpecifications() {
80 'name' => pht('Path'),
85 'name' => pht('Local Name'),
89 'hostartifact' => array(
90 'name' => pht('Host Artifact'),