/**
  * @param Payload $payload
  * @return string
  */
 protected function getRepositoryPath(Payload $payload)
 {
     $repositoryRelativePath = sprintf($this->getSettingValue(self::OPTION_DIRECTORY), $payload->getRepository()->getName());
     $repositoryBasePath = $this->getSettingValue(self::OPTION_DOCUMENTROOT, '/');
     $repositoryBasePath = sprintf($repositoryBasePath, substr($payload->getRef(), 11));
     $repositoryLocalPath = $repositoryBasePath . $repositoryRelativePath;
     return $repositoryLocalPath;
 }
 /**
  * Analyse $payload and return TRUE if this plugin should
  * be triggered in processing the payload.
  *
  * @param Payload $payload
  * @return boolean
  */
 public function trigger(Payload $payload)
 {
     $url = $payload->getRepository()->getUrl();
     $branch = $payload->getRepository()->getMasterBranch();
     $isEnabled = (bool) $this->getSettingValue(self::OPTION_ENABLED, TRUE);
     $matchesRepository = $url === $this->getSettingValue(self::OPTION_REPOSITORY, $url);
     $matchesBranch = $payload->getRef() === 'refs/heads/' . $this->getSettingValue(self::OPTION_BRANCH, $branch);
     return $matchesRepository && $matchesBranch && $isEnabled;
 }
 /**
  * Upload the extension contained in repository to
  * the official TYPO3 extension repository using
  * credentials stored in the .typo3credentials file
  * as a "username:password" value.
  *
  * @param Payload $payload
  * @return void
  * @throws \RuntimeException
  */
 public function process(Payload $payload)
 {
     $sha1 = $payload->getHead()->getId();
     $tag = substr($payload->getRef(), strlen(self::PATTERN_TAG_HEAD));
     $this->validateVersionNumber($tag);
     // additional settings not requiring validation.
     $url = $this->getSettingValue(self::OPTION_URL, $payload->getRepository()->resolveApiUrl(Repository::API_URL_CLONE));
     // look for an upload comment in settings; if not found there, use Payload HEAD's message body
     $comment = $this->getSettingValue(self::OPTION_COMMENT, $payload->getHead()->getMessage());
     // validation: credentials file and local directory path.
     $directory = $this->getSettingValue(self::OPTION_DIRECTORY);
     $directory = rtrim($directory, '/') . '/';
     $directory .= $sha1 . '/' . $this->getWorkingDirectoryName($payload);
     $credentialsFile = $this->getSettingValue(self::OPTION_CREDENTIALSFILE, GIZZLE_HOME . self::CREDENTIALS_FILE);
     $this->validateCredentialsFile($credentialsFile);
     list($username, $password) = $this->readUploadCredentials($credentialsFile);
     // initializing build directory and cloning source
     $clone = $this->getGitClonePlugin();
     $clonePluginSettings = $this->getSubPluginSettings('\\NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\ClonePlugin', array(ClonePlugin::OPTION_GITCOMMAND => $this->getSettingValue(self::OPTION_GITCOMMAND, ClonePlugin::DEFAULT_GITCOMMAND), ClonePlugin::OPTION_DIRECTORY => $directory, ClonePlugin::OPTION_SINGLE => TRUE, ClonePlugin::OPTION_BRANCH => $tag, ClonePlugin::OPTION_DEPTH => 1));
     $clone->initialize($clonePluginSettings);
     $this->createWorkingDirectory($directory);
     $this->validateDirectory($directory);
     $clone->process($payload);
     // a large, properly formatted data file.
     $comment = sprintf($comment, $url);
     try {
         $output = $this->getUploader()->upload($directory, $username, $password, $comment);
     } catch (\SoapFault $error) {
         throw new \RuntimeException($error->getMessage(), $error->getCode());
     }
     // cleanup and messages
     if (TRUE === (bool) $this->getSettingValue(self::OPTION_REMOVEBUILD, FALSE)) {
         $this->removeWorkingDirectory($this->getSettingValue(self::OPTION_DIRECTORY), $sha1);
     }
     $payload->getResponse()->addOutputFromPlugin($this, $output);
 }
Esempio n. 4
0
 /**
  * This plugin will always trigger
  *
  * @param Payload $payload
  * @return boolean
  */
 public function trigger(Payload $payload)
 {
     $enabled = (bool) (TRUE === isset($this->settings[self::OPTION_ENABLED]) ? $this->settings[self::OPTION_ENABLED] : TRUE);
     $matchesBranch = TRUE === isset($this->settings[self::OPTION_BRANCH]) ? 'refs/heads/' . $this->settings[self::OPTION_BRANCH] === $payload->getRef() : TRUE;
     return $enabled && $matchesBranch;
 }