Exemplo n.º 1
0
 /**
  * Executes this task
  *
  * Options:
  *   command: The command to execute
  *   rollbackCommand: The command to execute as a rollback (optional)
  *
  * @param \TYPO3\Surf\Domain\Model\Node $node
  * @param \TYPO3\Surf\Domain\Model\Application $application
  * @param \TYPO3\Surf\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  * @throws \TYPO3\Surf\Exception\InvalidConfigurationException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if (!isset($options['folders'])) {
         return;
     }
     $folders = $options['folders'];
     if (!is_array($folders)) {
         $folders = array($folders);
     }
     $replacePaths = array('{deploymentPath}' => escapeshellarg($application->getDeploymentPath()), '{sharedPath}' => escapeshellarg($application->getSharedPath()), '{releasePath}' => escapeshellarg($deployment->getApplicationReleasePath($application)), '{currentPath}' => escapeshellarg($application->getReleasesPath() . '/current'), '{previousPath}' => escapeshellarg($application->getReleasesPath() . '/previous'));
     $commands = array();
     $username = isset($options['username']) ? $options['username'] . '@' : '';
     $hostname = $node->getHostname();
     $port = $node->hasOption('port') ? '-P ' . escapeshellarg($node->getOption('port')) : '';
     foreach ($folders as $folderPair) {
         if (!is_array($folderPair) || count($folderPair) !== 2) {
             throw new InvalidConfigurationException('Each rsync folder definition must be an array of exactly two folders', 1405599056);
         }
         $sourceFolder = rtrim(str_replace(array_keys($replacePaths), $replacePaths, $folderPair[0]), '/') . '/';
         $targetFolder = rtrim(str_replace(array_keys($replacePaths), $replacePaths, $folderPair[1]), '/') . '/';
         $commands[] = "rsync -avz --delete -e ssh {$sourceFolder} {$username}{$hostname}:{$targetFolder}";
     }
     $ignoreErrors = isset($options['ignoreErrors']) && $options['ignoreErrors'] === true;
     $logOutput = !(isset($options['logOutput']) && $options['logOutput'] === false);
     $localhost = new Node('localhost');
     $localhost->setHostname('localhost');
     $this->shell->executeOrSimulate($commands, $localhost, $deployment, $ignoreErrors, $logOutput);
 }
Exemplo n.º 2
0
 /**
  * Rollback this task
  *
  * @param \TYPO3\Surf\Domain\Model\Node $node
  * @param \TYPO3\Surf\Domain\Model\Application $application
  * @param \TYPO3\Surf\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  */
 public function rollback(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if (!isset($options['rollbackCommand'])) {
         return;
     }
     $replacePaths = array('{deploymentPath}' => $application->getDeploymentPath(), '{sharedPath}' => $application->getSharedPath(), '{releasePath}' => $deployment->getApplicationReleasePath($application), '{currentPath}' => $application->getReleasesPath() . '/current', '{previousPath}' => $application->getReleasesPath() . '/previous');
     $command = $options['rollbackCommand'];
     $command = str_replace(array_keys($replacePaths), $replacePaths, $command);
     $this->shell->execute($command, $node, $deployment, true);
 }
Exemplo n.º 3
0
 /**
  * Executes this task
  *
  * @param \TYPO3\Surf\Domain\Model\Node $node
  * @param \TYPO3\Surf\Domain\Model\Application $application
  * @param \TYPO3\Surf\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  * @throws \TYPO3\Surf\Exception\TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     $deploymentPath = $application->getDeploymentPath();
     $sharedPath = $application->getSharedPath();
     $releasesPath = $application->getReleasesPath();
     $releaseIdentifier = $deployment->getReleaseIdentifier();
     $releasePath = $deployment->getApplicationReleasePath($application);
     $result = $this->shell->execute('test -d ' . $deploymentPath, $node, $deployment, true);
     if ($result === false) {
         throw new \TYPO3\Surf\Exception\TaskExecutionException('Deployment directory "' . $deploymentPath . '" does not exist on node ' . $node->getName(), 1311003253);
     }
     $commands = array('mkdir -p ' . $releasesPath, 'mkdir -p ' . $sharedPath, 'mkdir -p ' . $releasePath, 'cd ' . $releasesPath . ';ln -snf ./' . $releaseIdentifier . ' next');
     $this->shell->executeOrSimulate($commands, $node, $deployment);
 }
Exemplo n.º 4
0
 /**
  * Execute this task
  *
  * @param \TYPO3\Surf\Domain\Model\Node $node
  * @param \TYPO3\Surf\Domain\Model\Application $application
  * @param \TYPO3\Surf\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     $options = array('directories' => array('shared/Data/Logs', 'shared/Data/Persistent', 'shared/Configuration'), 'baseDirectory' => $application->getDeploymentPath());
     parent::execute($node, $application, $deployment, $options);
 }