/** * 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 * @todo Make the removal of a failed release configurable, sometimes it's necessary to inspect a failed release */ public function rollback(Node $node, Application $application, Deployment $deployment, array $options = array()) { $releasesPath = $application->getReleasesPath(); $releasePath = $deployment->getApplicationReleasePath($application); $commands = array('rm ' . $releasesPath . '/next', 'rm -rf ' . $releasePath); $this->shell->execute($commands, $node, $deployment, true); }
/** * 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 * @throws \TYPO3\Surf\Exception\TaskExecutionException * @throws \TYPO3\Surf\Exception\InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $options['username'] = isset($options['username']) ? $options['username'] . '@' : ''; $targetReleasePath = $deployment->getApplicationReleasePath($application); $configurationPath = $deployment->getDeploymentConfigurationPath() . '/'; if (!is_dir($configurationPath)) { return; } $encryptedConfiguration = glob($configurationPath . '*.yaml.encrypted'); if (count($encryptedConfiguration) > 0) { throw new \TYPO3\Surf\Exception\TaskExecutionException('You have sealed configuration files, please open the configuration for "' . $deployment->getName() . '"', 1317229449); } $configurations = glob($configurationPath . '*.yaml'); $commands = array(); foreach ($configurations as $configuration) { $targetConfigurationPath = dirname(str_replace($configurationPath, '', $configuration)); if ($node->isLocalhost()) { $commands[] = "mkdir -p '{$targetReleasePath}/Configuration/{$targetConfigurationPath}/'"; $commands[] = "cp {$configuration} {$targetReleasePath}/Configuration/{$targetConfigurationPath}/"; } else { $username = $options['username']; $hostname = $node->getHostname(); $sshPort = $node->hasOption('port') ? '-p ' . escapeshellarg($node->getOption('port')) : ''; $scpPort = $node->hasOption('port') ? '-P ' . escapeshellarg($node->getOption('port')) : ''; $commands[] = "ssh {$sshPort} {$username}{$hostname} 'mkdir -p {$targetReleasePath}/Configuration/{$targetConfigurationPath}/'"; $commands[] = "scp {$scpPort} {$configuration} {$username}{$hostname}:{$targetReleasePath}/Configuration/{$targetConfigurationPath}/"; } } $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->executeOrSimulate($commands, $localhost, $deployment); }
/** * 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 * @throws \TYPO3\Surf\Exception\TaskExecutionException * @throws \TYPO3\Surf\Exception\InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $options['username'] = isset($options['username']) ? $options['username'] . '@' : ''; $targetReleasePath = $deployment->getApplicationReleasePath($application); $configurationPath = $deployment->getDeploymentConfigurationPath() . '/'; if (!is_dir($configurationPath)) { return; } $configurations = glob($configurationPath . '*'); $commands = array(); foreach ($configurations as $configuration) { $targetConfigurationPath = dirname(str_replace($configurationPath, '', $configuration)); if ($node->isLocalhost()) { $commands[] = "mkdir -p '{$targetReleasePath}/Configuration/{$targetConfigurationPath}/'"; $commands[] = "cp {$configuration} {$targetReleasePath}/Configuration/{$targetConfigurationPath}/"; } else { $username = $options['username']; $hostname = $node->getHostname(); $sshPort = $node->hasOption('port') ? '-p ' . escapeshellarg($node->getOption('port')) : ''; $scpPort = $node->hasOption('port') ? '-P ' . escapeshellarg($node->getOption('port')) : ''; $commands[] = "ssh {$sshPort} {$username}{$hostname} 'mkdir -p {$targetReleasePath}/Configuration/{$targetConfigurationPath}/'"; $commands[] = "scp {$scpPort} {$configuration} {$username}{$hostname}:{$targetReleasePath}/Configuration/{$targetConfigurationPath}/"; } } $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->executeOrSimulate($commands, $localhost, $deployment); }
/** * @param \TYPO3\Surf\Domain\Model\Node $node * @param \TYPO3\Surf\Domain\Model\Application $application * @param \TYPO3\Surf\Domain\Model\Deployment $deployment * @param array $options * @throws \TYPO3\Surf\Exception\TaskExecutionException * @return void */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $applicationReleasePath = $deployment->getApplicationReleasePath($application); $command = 'curl -sL http://beard.famelo.com > beard.phar'; $command = sprintf('cd %s && %s && chmod +x beard.phar', escapeshellarg($applicationReleasePath), $command); $this->shell->executeOrSimulate($command, $node, $deployment); }
/** * 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 * @throws \TYPO3\Surf\Exception\TaskExecutionException * @throws \TYPO3\Surf\Exception\InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $configurationFileExtension = isset($options['configurationFileExtension']) ? $options['configurationFileExtension'] : 'yaml'; $targetReleasePath = $deployment->getApplicationReleasePath($application); $configurationPath = $deployment->getDeploymentConfigurationPath(); if (!is_dir($configurationPath)) { return; } $commands = array(); $configurationFiles = Files::readDirectoryRecursively($configurationPath, $configurationFileExtension); foreach ($configurationFiles as $configuration) { $targetConfigurationPath = dirname(str_replace($configurationPath, '', $configuration)); $escapedSourcePath = escapeshellarg($configuration); $escapedTargetPath = escapeshellarg(Files::concatenatePaths(array($targetReleasePath, 'Configuration', $targetConfigurationPath)) . '/'); if ($node->isLocalhost()) { $commands[] = 'mkdir -p ' . $escapedTargetPath; $commands[] = 'cp ' . $escapedSourcePath . ' ' . $escapedTargetPath; } else { $username = isset($options['username']) ? $options['username'] . '@' : ''; $hostname = $node->getHostname(); $sshPort = isset($options['port']) ? '-p ' . escapeshellarg($options['port']) . ' ' : ''; $scpPort = isset($options['port']) ? '-P ' . escapeshellarg($options['port']) . ' ' : ''; $createDirectoryCommand = '"mkdir -p ' . $escapedTargetPath . '"'; $commands[] = "ssh {$sshPort}{$username}{$hostname} {$createDirectoryCommand}"; $commands[] = "scp {$scpPort}{$escapedSourcePath} {$username}{$hostname}:\"{$escapedTargetPath}\""; } } $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->executeOrSimulate($commands, $localhost, $deployment); }
/** * 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 */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $targetReleasePath = $deployment->getApplicationReleasePath($application); $context = $application->getContext(); $commands = array("cd {$targetReleasePath}/Configuration", "rm -Rf " . $context . "/*", "if [ -d " . $context . " ]; then rmdir " . $context . "; fi", "mkdir -p ../../../shared/Configuration/" . $context . "", "ln -snf ../../../shared/Configuration/" . $context . " " . $context . ""); $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * 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); }
/** * 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()) { if (!$application instanceof \TYPO3\Surf\Application\TYPO3\Flow) { throw new \TYPO3\Surf\Exception\InvalidConfigurationException(sprintf('Flow application needed for UnitTestTask, got "%s"', get_class($application)), 1358866042); } $targetPath = $deployment->getApplicationReleasePath($application); $this->shell->executeOrSimulate('cd ' . $targetPath . ' && phpunit -c Build/' . $application->getBuildEssentialsDirectoryName() . '/PhpUnit/UnitTests.xml', $node, $deployment); }
/** * 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); }
/** * Execute this task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @throws InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (!$application instanceof \TYPO3\Surf\Application\TYPO3\Flow) { throw new InvalidConfigurationException(sprintf('Flow application needed for PublishResourcesTask, got "%s"', get_class($application)), 1425568379); } if ($application->getVersion() >= '3.0') { $targetPath = $deployment->getApplicationReleasePath($application); $this->shell->executeOrSimulate('cd ' . $targetPath . ' && ' . 'FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . 'typo3.flow:resource:publish', $node, $deployment); } }
/** * 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()) { if (!isset($options['directories']) || !is_array($options['directories']) || $options['directories'] === array()) { return; } $commands = array('cd ' . $deployment->getApplicationReleasePath($application)); foreach ($options['directories'] as $path) { $commands[] = 'mkdir -p ' . $path; } $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * @param \TYPO3\Surf\Domain\Model\Node $node * @param \TYPO3\Surf\Domain\Model\Application $application * @param \TYPO3\Surf\Domain\Model\Deployment $deployment * @param array $options * @throws \TYPO3\Surf\Exception\TaskExecutionException * @return void */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $applicationReleasePath = $deployment->getApplicationReleasePath($application); if (isset($options['composerDownloadCommand'])) { $composerDownloadCommand = $options['composerDownloadCommand']; } else { $composerDownloadCommand = 'curl -s https://getcomposer.org/installer | php'; } $command = sprintf('cd %s && %s', escapeshellarg($applicationReleasePath), $composerDownloadCommand); $this->shell->executeOrSimulate($command, $node, $deployment); }
/** * 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 */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (!isset($options['symlinks']) || !is_array($options['symlinks'])) { return; } $commands = array('cd ' . $deployment->getApplicationReleasePath($application)); foreach ($options['symlinks'] as $sourcePath => $linkPath) { $commands[] = 'ln -s ' . $sourcePath . ' ' . $linkPath; } $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * Executes this task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @return void * @throws InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (empty($options['branch']) || !empty($options['tag'])) { return; } $quietFlag = isset($options['verbose']) && $options['verbose'] ? '' : '-q'; $commands = array(); $commands[] = 'cd ' . escapeshellarg($deployment->getApplicationReleasePath($application)); $commands[] = 'if [ -d \'.git\' ] && hash git 2>/dev/null; then ' . 'git branch -f ' . escapeshellarg($options['branch']) . ' deploy && ' . 'git checkout ' . $quietFlag . ' ' . escapeshellarg($options['branch']) . ' && ' . 'git branch -D deploy; ' . 'fi;'; $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * 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()) { if (!$application instanceof \TYPO3\Surf\Application\TYPO3\Flow) { throw new \TYPO3\Surf\Exception\InvalidConfigurationException(sprintf('Flow application needed for MigrateTask, got "%s"', get_class($application)), 1358863288); } $commandPackageKey = 'typo3.flow'; if ($application->getVersion() < '2.0') { $commandPackageKey = 'typo3.flow3'; } $targetPath = $deployment->getApplicationReleasePath($application); $this->shell->executeOrSimulate('cd ' . $targetPath . ' && FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . $commandPackageKey . ':doctrine:migrate', $node, $deployment); }
/** * 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 * @throws \TYPO3\Surf\Exception\InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (!$application instanceof \TYPO3\Surf\Application\TYPO3\Flow) { throw new \TYPO3\Surf\Exception\InvalidConfigurationException(sprintf('Flow application needed for ImportSiteTask, got "%s"', get_class($application)), 1358863473); } if (!isset($options['sitePackageKey'])) { throw new \TYPO3\Surf\Exception\InvalidConfigurationException(sprintf('"sitePackageKey" option not set for application "%s"', $application->getName()), 1312312646); } $targetPath = $deployment->getApplicationReleasePath($application); $sitePackageKey = $options['sitePackageKey']; $this->shell->executeOrSimulate('cd ' . $targetPath . ' && FLOW_CONTEXT=' . $application->getContext() . ' ./flow typo3.neos:site:import --package-key ' . $sitePackageKey, $node, $deployment); }
/** * @param \TYPO3\Surf\Domain\Model\Node $node * @param \TYPO3\Surf\Domain\Model\Application $application * @param \TYPO3\Surf\Domain\Model\Deployment $deployment * @param array $options * @throws \TYPO3\Surf\Exception\TaskExecutionException * @return void */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if ($application->getOption('transferMethod') == 'rsync') { $path = $deployment->getWorkspacePath($application); $node = $deployment->getNode('localhost'); $command = 'beard patch'; } else { $patch = $deployment->getApplicationReleasePath($application); $command = $application->getOption('phpPath') . ' beard.phar patch'; } $command = sprintf('cd %s && %s', escapeshellarg($path), $command); $this->shell->executeOrSimulate($command, $node, $deployment); }
/** * Execute this task * * Options: * remote: The git remote to use * refspec: The refspec to push * recurseIntoSubmodules: If true, push submodules as well (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['remote'])) { throw new InvalidConfigurationException('Missing "remote" option for PushTask', 1314186541); } if (!isset($options['refspec'])) { throw new InvalidConfigurationException('Missing "refspec" option for PushTask', 1314186553); } $targetPath = $deployment->getApplicationReleasePath($application); $this->shell->executeOrSimulate(sprintf('cd ' . $targetPath . '; git push -f %s %s', $options['remote'], $options['refspec']), $node, $deployment); if (isset($options['recurseIntoSubmodules']) && $options['recurseIntoSubmodules'] === true) { $this->shell->executeOrSimulate(sprintf('cd ' . $targetPath . '; git submodule foreach \'git push -f %s %s\'', $options['remote'], $options['refspec']), $node, $deployment); } }
/** * Determines the path to the working directory and the target node by given options * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @return string */ protected function determineWorkingDirectoryAndTargetNode(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (!isset($this->workingDirectory) || !isset($this->targetNode)) { if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) { $targetPath = $deployment->getWorkspacePath($application); $node = $deployment->getNode('localhost'); } else { $targetPath = $deployment->getApplicationReleasePath($application); } $applicationRootDirectory = isset($options['applicationRootDirectory']) ? $options['applicationRootDirectory'] : ''; $this->workingDirectory = $targetPath . '/' . $applicationRootDirectory; $this->targetNode = $node; } }
/** * 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 * @throws \TYPO3\Surf\Exception\InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (!$application instanceof \TYPO3\Surf\Application\TYPO3\Flow) { throw new \TYPO3\Surf\Exception\InvalidConfigurationException(sprintf('Flow application needed for RunCommandTask, got "%s"', get_class($application)), 1358863336); } if (!isset($options['command'])) { throw new \TYPO3\Surf\Exception\InvalidConfigurationException('Missing option "command" for RunCommandTask', 1319201396); } $ignoreErrors = isset($options['ignoreErrors']) && $options['ignoreErrors'] === true; $logOutput = !(isset($options['logOutput']) && $options['logOutput'] === false); $targetPath = $deployment->getApplicationReleasePath($application); $arguments = $this->buildCommandArguments($options); $command = 'cd ' . $targetPath . ' && FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . $options['command'] . $arguments; $this->shell->executeOrSimulate($command, $node, $deployment, $ignoreErrors, $logOutput); }
/** * 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()) { if (!$application instanceof \TYPO3\Surf\Application\TYPO3\Flow) { throw new \TYPO3\Surf\Exception\InvalidConfigurationException(sprintf('Flow application needed for SetFilePermissionsTask, got "%s"', get_class($application)), 1358863436); } $targetPath = $deployment->getApplicationReleasePath($application); $arguments = isset($options['shellUsername']) ? $options['shellUsername'] : (isset($options['username']) ? $options['username'] : '******'); $arguments .= ' ' . (isset($options['webserverUsername']) ? $options['webserverUsername'] : '******'); $arguments .= ' ' . (isset($options['webserverGroupname']) ? $options['webserverGroupname'] : 'www-data'); $commandPackageKey = 'typo3.flow'; if ($application->getVersion() < '2.0') { $commandPackageKey = 'typo3.flow3'; } $this->shell->executeOrSimulate('cd ' . $targetPath . ' && FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . $commandPackageKey . ':core:setfilepermissions ' . $arguments, $node, $deployment); }
/** * Executes this task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @return void * @throws InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === TRUE) { $gitRootPath = $deployment->getWorkspacePath($application); } else { $gitRootPath = $deployment->getApplicationReleasePath($application); } // $quietFlag = (isset($options['verbose']) && $options['verbose']) ? '' : '-q'; if (!empty($options['nodeName'])) { $node = $deployment->getNode($options['nodeName']); if ($node === NULL) { throw new InvalidConfigurationException(sprintf('Node "%s" not found', $options['nodeName']), 1413298085); } } $commands = array('cd ' . escapeshellarg($gitRootPath), 'if [ -d \'.git\' ] && hash git 2>/dev/null; then ' . 'git checkout -- .; ' . 'fi;'); $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * 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 */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $targetReleasePath = $deployment->getApplicationReleasePath($application); if ($application instanceof \TYPO3\Surf\Application\TYPO3\Flow) { $context = $application->getContext(); } else { $context = 'Production'; } $commands = array("cd {$targetReleasePath}/Configuration", "if [ -d {$context} ]; then rm -Rf {$context}; fi", "mkdir -p ../../../shared/Configuration/{$context}"); if (strpos($context, '/') !== false) { $baseContext = dirname($context); $commands[] = "mkdir -p {$baseContext}"; $commands[] = "ln -snf ../../../../shared/Configuration/{$context} {$context}"; } else { $commands[] = "ln -snf ../../../shared/Configuration/{$context} {$context}"; } $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * @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()) { if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) { $composerRootPath = $deployment->getWorkspacePath($application); } else { $composerRootPath = $deployment->getApplicationReleasePath($application); } if (isset($options['nodeName'])) { $node = $deployment->getNode($options['nodeName']); if ($node === null) { throw new \TYPO3\Surf\Exception\InvalidConfigurationException(sprintf('Node "%s" not found', $options['nodeName']), 1369759412); } } if ($this->composerManifestExists($composerRootPath, $node, $deployment)) { $command = $this->buildComposerInstallCommand($composerRootPath, $options); $this->shell->executeOrSimulate($command, $node, $deployment); } }
/** * Execute this task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @return void * @throws InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (!$application instanceof FlowApplication) { throw new InvalidConfigurationException(sprintf('Flow application needed for MigrateTask, got "%s"', get_class($application)), 1429774224); } if (!isset($options['flushCacheList']) || trim($options['flushCacheList']) === '') { throw new InvalidConfigurationException('Missing option "flushCacheList" for FlushCacheListTask', 1429774229); } if ($application->getVersion() >= '2.3') { $caches = is_array($options['flushCacheList']) ? $options['flushCacheList'] : explode(',', $options['flushCacheList']); $targetPath = $deployment->getApplicationReleasePath($application); foreach ($caches as $cache) { $deployment->getLogger()->debug(sprintf('Flush cache with identifier "%s"', $cache)); $this->shell->executeOrSimulate('cd ' . $targetPath . ' && ' . 'FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . sprintf('typo3.flow:cache:flushone --identifier %s', $cache), $node, $deployment); } } else { throw new InvalidConfigurationException(sprintf('FlushCacheListTask is available since Flow Framework 2.3, your application version is "%s"', $application->getVersion()), 1434126060); } }
/** * 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 */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $targetReleasePath = $deployment->getApplicationReleasePath($application); $applicationRootDirectory = isset($options['applicationRootDirectory']) ? trim($options['applicationRootDirectory'], '\\/') : ''; $workingDirectory = escapeshellarg(rtrim("{$targetReleasePath}/{$applicationRootDirectory}", '/')); $relativeDataPath = '../../shared/Data'; if (!empty($applicationRootDirectory)) { $relativeDataPath = str_repeat('../', substr_count(trim($applicationRootDirectory, '/'), '/') + 1) . $relativeDataPath; } $commands = array("cd {$workingDirectory}", "{ [ -d {$relativeDataPath}/fileadmin ] || mkdir -p {$relativeDataPath}/fileadmin ; }", "{ [ -d {$relativeDataPath}/uploads ] || mkdir -p {$relativeDataPath}/uploads ; }", "ln -sf {$relativeDataPath}/fileadmin ./fileadmin", "ln -sf {$relativeDataPath}/uploads ./uploads"); if (isset($options['directories']) && is_array($options['directories'])) { foreach ($options['directories'] as $directory) { $targetDirectory = escapeshellarg("{$relativeDataPath}/{$directory}"); $commands[] = '{ [ -d ' . $targetDirectory . ' ] || mkdir -p ' . $targetDirectory . ' ; }'; $commands[] = 'ln -sf ' . escapeshellarg(str_repeat('../', substr_count(trim($directory, '/'), '/')) . "{$relativeDataPath}/{$directory}") . ' ' . escapeshellarg($directory); } } $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * Executes this task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @return void * @throws TaskExecutionException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === TRUE) { $rootPath = $deployment->getWorkspacePath($application); } else { $rootPath = $deployment->getApplicationReleasePath($application); } if (isset($options['relativeRootPath'])) { $rootPath .= $options['relativeRootPath']; } if (!empty($options['nodeName'])) { $node = $deployment->getNode($options['nodeName']); if ($node === NULL) { throw new InvalidConfigurationException(sprintf('Node "%s" not found', $options['nodeName']), 1414781227); } } $commands = array(); $commands[] = 'cd ' . escapeshellarg($rootPath); $commands[] = 'if [ "`which npm`" != "" ] && [ -f "package.json" ]; then ' . 'npm install --loglevel error; ' . 'fi'; $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * Executes this task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @return void * @throws InvalidConfigurationException * @throws TaskExecutionException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === TRUE) { $rootPath = $deployment->getWorkspacePath($application); } else { $rootPath = $deployment->getApplicationReleasePath($application); } if (isset($options['relativeRootPath'])) { $rootPath .= $options['relativeRootPath']; } if (!empty($options['nodeName'])) { $node = $deployment->getNode($options['nodeName']); if ($node === NULL) { throw new InvalidConfigurationException(sprintf('Node "%s" not found', $options['nodeName']), 1414781227); } } $commands = array(); $commands[] = 'cd ' . escapeshellarg($rootPath); $commands[] = 'if hash gulp 2>/dev/null && [ -f gulpfile.js ]; then ' . 'gulp build; ' . 'fi;'; $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * Executes this task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @return void * @throws InvalidConfigurationException * @throws TaskExecutionException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (!empty($options['disableDeploymentTag'])) { return; } if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === TRUE) { $gitRootPath = $deployment->getWorkspacePath($application); } else { $gitRootPath = $deployment->getApplicationReleasePath($application); } $tagPrefix = isset($options['deploymentTagPrefix']) ? $options['deploymentTagPrefix'] : 'server-'; $tagName = preg_replace('/[^a-zA-Z0-9-_\\.]*/', '', $tagPrefix . $node->getName()); $quietFlag = isset($options['verbose']) && $options['verbose'] ? '' : '-q'; if (!empty($options['nodeName'])) { $node = $deployment->getNode($options['nodeName']); if ($node === NULL) { throw new InvalidConfigurationException(sprintf('Node "%s" not found', $options['nodeName']), 1408441582); } } $commands = array('cd ' . escapeshellarg($gitRootPath), 'git tag --force -- ' . escapeshellarg($tagName), 'git push origin --force ' . $quietFlag . ' -- ' . escapeshellarg($tagName)); $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * Rollback this task by removing the revision file * * @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()) { $releasePath = $deployment->getApplicationReleasePath($application); $this->shell->execute('rm -f ' . $releasePath . 'REVISION', $node, $deployment, true); }