[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class HarbormasterUploadArtifactBuildStepImplementation 4 extends HarbormasterBuildStepImplementation { 5 6 public function getName() { 7 return pht('Upload File'); 8 } 9 10 public function getGenericDescription() { 11 return pht('Upload a file from a host to Phabricator.'); 12 } 13 14 public function getDescription() { 15 return pht( 16 'Upload %s from %s.', 17 $this->formatSettingForDescription('path'), 18 $this->formatSettingForDescription('hostartifact')); 19 } 20 21 public function execute( 22 HarbormasterBuild $build, 23 HarbormasterBuildTarget $build_target) { 24 25 $settings = $this->getSettings(); 26 $variables = $build_target->getVariables(); 27 28 $path = $this->mergeVariables( 29 'vsprintf', 30 $settings['path'], 31 $variables); 32 33 $artifact = $build->loadArtifact($settings['hostartifact']); 34 35 $lease = $artifact->loadDrydockLease(); 36 37 $interface = $lease->getInterface('filesystem'); 38 39 // TODO: Handle exceptions. 40 $file = $interface->saveFile($path, $settings['name']); 41 42 // Insert the artifact record. 43 $artifact = $build->createArtifact( 44 $build_target, 45 $settings['name'], 46 HarbormasterBuildArtifact::TYPE_FILE); 47 $artifact->setArtifactData(array( 48 'filePHID' => $file->getPHID(), 49 )); 50 $artifact->save(); 51 } 52 53 public function getArtifactInputs() { 54 return array( 55 array( 56 'name' => pht('Upload From Host'), 57 'key' => $this->getSetting('hostartifact'), 58 'type' => HarbormasterBuildArtifact::TYPE_HOST, 59 ), 60 ); 61 } 62 63 public function getArtifactOutputs() { 64 return array( 65 array( 66 'name' => pht('Uploaded File'), 67 'key' => $this->getSetting('name'), 68 'type' => HarbormasterBuildArtifact::TYPE_FILE, 69 ), 70 ); 71 } 72 73 public function getFieldSpecifications() { 74 return array( 75 'path' => array( 76 'name' => pht('Path'), 77 'type' => 'text', 78 'required' => true, 79 ), 80 'name' => array( 81 'name' => pht('Local Name'), 82 'type' => 'text', 83 'required' => true, 84 ), 85 'hostartifact' => array( 86 'name' => pht('Host Artifact'), 87 'type' => 'text', 88 'required' => true, 89 ), 90 ); 91 } 92 93 }
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 |