Path: blob/master/src/applications/harbormaster/step/HarbormasterUploadArtifactBuildStepImplementation.php
12256 views
<?php12final class HarbormasterUploadArtifactBuildStepImplementation3extends HarbormasterBuildStepImplementation {45public function getName() {6return pht('Upload File');7}89public function getGenericDescription() {10return pht('Upload a file.');11}1213public function getBuildStepGroupKey() {14return HarbormasterPrototypeBuildStepGroup::GROUPKEY;15}1617public function getDescription() {18return pht(19'Upload %s from %s.',20$this->formatSettingForDescription('path'),21$this->formatSettingForDescription('hostartifact'));22}2324public function execute(25HarbormasterBuild $build,26HarbormasterBuildTarget $build_target) {27$viewer = PhabricatorUser::getOmnipotentUser();2829$settings = $this->getSettings();30$variables = $build_target->getVariables();3132$path = $this->mergeVariables(33'vsprintf',34$settings['path'],35$variables);3637$artifact = $build_target->loadArtifact($settings['hostartifact']);38$impl = $artifact->getArtifactImplementation();39$lease = $impl->loadArtifactLease($viewer);4041$interface = $lease->getInterface('filesystem');4243// TODO: Handle exceptions.44$file = $interface->saveFile($path, $settings['name']);4546// Insert the artifact record.47$artifact = $build_target->createArtifact(48$viewer,49$settings['name'],50HarbormasterFileArtifact::ARTIFACTCONST,51array(52'filePHID' => $file->getPHID(),53));54}5556public function getArtifactInputs() {57return array(58array(59'name' => pht('Upload From Host'),60'key' => $this->getSetting('hostartifact'),61'type' => HarbormasterHostArtifact::ARTIFACTCONST,62),63);64}6566public function getArtifactOutputs() {67return array(68array(69'name' => pht('Uploaded File'),70'key' => $this->getSetting('name'),71'type' => HarbormasterHostArtifact::ARTIFACTCONST,72),73);74}7576public function getFieldSpecifications() {77return array(78'path' => array(79'name' => pht('Path'),80'type' => 'text',81'required' => true,82),83'name' => array(84'name' => pht('Local Name'),85'type' => 'text',86'required' => true,87),88'hostartifact' => array(89'name' => pht('Host Artifact'),90'type' => 'text',91'required' => true,92),93);94}9596}979899