/** * @param Node $sourceNode * @param string $sourcePath * @param Node $destinationNode * @param string $destinationPath * @param Deployment $deployment * @param array $options * @return void * @throws InvalidConfigurationException * @throws TaskExecutionException */ public function sync(Node $sourceNode, $sourcePath, Node $destinationNode, $destinationPath, Deployment $deployment, $options) { // first override $this->flags with $options['rsyncFlags'] if (empty($options['rsyncFlags']) === FALSE) { $flagOptions = array_replace_recursive($this->flags, $options['rsyncFlags']); } else { $flagOptions = $this->flags; } if ($sourceNode->isLocalhost() === FALSE && $destinationNode->isLocalhost() === FALSE) { throw new InvalidConfigurationException('Just one external host is allowed!', 1408805638); } // override $flagOptions $externalNode = $this->getFirstExternalNode($sourceNode, $destinationNode); if ($externalNode instanceof Node && $externalNode->hasOption('port')) { $flagOptions['rsh'] = 'ssh -p ' . (int) $externalNode->getOption('port') . ' -o BatchMode=yes'; } if (!isset($options['keepVcs']) || empty($options['keepVcs'])) { if (empty($options['context']) || !preg_match('/^Development.*/', $options['context'])) { $flagOptions['exclude'][] = '.git'; $flagOptions['exclude'][] = '.svn'; } } $command = array_merge(array($this->rsyncCommand), $this->getFlags($flagOptions)); $command[] = $this->getFullPath($sourceNode, $sourcePath); $command[] = $this->getFullPath($destinationNode, $destinationPath); $this->shell->executeOrSimulate('mkdir -p ' . escapeshellarg($destinationPath), $destinationNode, $deployment); $this->shell->executeOrSimulate(implode(' ', $command), $deployment->getNode('localhost'), $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}' => $application->getDeploymentPath(), '{sharedPath}' => $application->getSharedPath(), '{releasePath}' => $deployment->getApplicationReleasePath($application), '{currentPath}' => $application->getReleasesPath() . '/current', '{previousPath}' => $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); }
/** * 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\InvalidConfigurationException * @return void */ 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 = \TYPO3\Flow\Utility\Files::readDirectoryRecursively($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(); $port = $node->hasOption('port') ? '-P ' . escapeshellarg($node->getOption('port')) : ''; $commands[] = "ssh {$port} {$username}{$hostname} 'mkdir -p {$targetReleasePath}/Configuration/{$targetConfigurationPath}/'"; $commands[] = "scp {$port} {$configuration} {$username}{$hostname}:{$targetReleasePath}/Configuration/{$targetConfigurationPath}/"; } } $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->executeOrSimulate($commands, $localhost, $deployment); }
/** * Executes this task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @throws TaskExecutionException * @return void */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $commands = $this->buildCommands($deployment, $application, 'coreapi', 'cacheapi:assurecachedirectoryiswriteable', $options); if (count($commands) > 0) { $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); $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 * * @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()) { $commands = $this->buildCommands($deployment, $application, 'coreapi', 'cacheapi:clearallcaches -hard true', $options); if (count($commands) > 0) { $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); $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 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()) { $commands = $this->buildCommands($deployment, $application, 'coreapi', 'extensionapi:createuploadfolders', $options); if (count($commands) > 0) { $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 * @throws InvalidConfigurationException * @return void */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $this->assertRequiredOptionsExist($options); $username = isset($options['username']) ? $options['username'] . '@' : ''; $hostname = $node->getHostname(); $port = $node->hasOption('port') ? '-P ' . escapeshellarg($node->getOption('port')) : ''; $commands[] = "mysqldump -h {$options['sourceHost']} -u{$options['sourceUser']} -p{$options['sourcePassword']} {$options['sourceDatabase']} | ssh {$port} {$username}{$hostname} 'mysql -h {$options['targetHost']} -u{$options['targetUser']} -p{$options['targetPassword']} {$options['targetDatabase']}'"; $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->executeOrSimulate($commands, $localhost, $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); }
/** * Executes the task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @throws InvalidConfigurationException * @throws TaskExecutionException * @return void */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if (empty($options['sourceNode']) || !is_array($options['sourceNode'])) { throw new InvalidConfigurationException('SourceNode is missing', 1409263510); } $sourceNode = $this->nodeFactory->getNodeByArray($options['sourceNode']); $options = array_replace_recursive($this->options, $options); $source = $this->getArgument($sourceNode, $application, $options['sourcePath'], $options['sourceFile']); $target = $this->getArgument($node, $application, $options['targetPath'], $options['targetFile']); $command = 'scp -o BatchMode=\'yes\' ' . $source . ' ' . $target; $this->shell->executeOrSimulate($command, $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); }
/** * 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 TaskExecutionException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $targetPath = isset($options['deploymentLogTargetPath']) ? $options['deploymentLogTargetPath'] : '.'; $fileName = !empty($options['deploymentLogFileName']) ? $options['deploymentLogFileName'] : 'deployment.log'; $optionsToLog = !empty($options['deploymentLogOptions']) ? $options['deploymentLogOptions'] : array('tag', 'branch', 'sha1'); $logContent = array(date('Y-m-d H:i:s (D)'), 'Application: ' . $application->getName(), 'Deployment: ' . $deployment->getName(), 'Status: ' . $deployment->getStatus()); foreach ($optionsToLog as $key) { if (!empty($options[$key])) { $logContent[] = $key . ' = ' . $options[$key]; } } $commands = array('cd ' . escapeshellarg($application->getReleasesPath()), 'echo ' . escapeshellarg(implode(' | ', $logContent)) . ' >> ' . rtrim($targetPath, '/') . '/' . $fileName); $this->shell->executeOrSimulate($commands, $node, $deployment); }
/** * @param Node $node * @param Deployment $deployment * @param array $options * @param Application $application * @return array * @throws TaskExecutionException */ protected function getCredentialsFromTypo3Cms(Node $node, Deployment $deployment, array $options = array(), Application $application) { $commands = $this->buildCommands($deployment, $application, 'coreapi', 'configurationapi:show DB', $options); if (empty($commands) === FALSE) { // Overwrite first command $commands[0] = 'cd ' . escapeshellarg($options['deploymentPath']); } else { throw new TaskExecutionException('Could not receive database credentials', 1409252547); } $returnedOutput = $this->shell->execute($commands, $node, $deployment, FALSE, FALSE); $returnedOutput = json_decode($returnedOutput, TRUE); if (empty($returnedOutput)) { throw new TaskExecutionException('Could not receive database credentials', 1409252546); } $credentials = array(); foreach ($returnedOutput as $key => $value) { switch ($key) { case 'username': $credentials['user'] = $value; break; default: $credentials[$key] = $value; break; } } return $credentials; }
/** * @param Node $node * @param Deployment $deployment * @param array $options * @param Application $application * @return string * @throws InvalidConfigurationException * @throws TaskExecutionException */ protected function getSharedPathFromNode(Node $node, Deployment $deployment, $options, Application $application) { if ($node->hasOption('sharedPath')) { $sharedPath = $node->getOption('sharedPath'); } else { if ($node->hasOption('deploymentPath')) { $deploymentPath = $node->getOption('deploymentPath'); } elseif (!empty($options['deploymentPath'])) { $deploymentPath = $options['deploymentPath']; } else { throw new InvalidConfigurationException('No deploymentPath defined!', 1414849872); } $webDir = $this->getWebDir($deployment, $application); if ($webDir !== '') { $deploymentPath = rtrim($deploymentPath, '/') . '/' . $webDir; } $commands = array(); $commands[] = 'cd ' . escapeshellarg($deploymentPath); $commands[] = 'readlink ' . escapeshellarg('fileadmin'); $output = $this->shell->execute($commands, $node, $deployment, TRUE); if (preg_match('/(.+)\\/fileadmin\\/?$/', trim($output), $matches)) { $sharedPath = $matches[1]; } else { $sharedPath = str_replace('htdocs', 'shared', $deploymentPath); } } if ($sharedPath[0] !== '/') { $sharedPath = rtrim($deploymentPath, '/') . '/' . $sharedPath; } return rtrim($sharedPath, '/') . '/'; }
/** * 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); }
/** * @test */ public function withAdditionalDirectoriesAndApplicationRootCreatesCorrectLinks() { $dataPath = '../../../../shared/Data'; $expectedCommands = array("cd '/releases/current/app/dir'", "{ [ -d {$dataPath}/fileadmin ] || mkdir -p {$dataPath}/fileadmin ; }", "{ [ -d {$dataPath}/uploads ] || mkdir -p {$dataPath}/uploads ; }", "ln -snvf {$dataPath}/fileadmin", "ln -snvf {$dataPath}/uploads", "{ [ -d '{$dataPath}/pictures' ] || mkdir -p '{$dataPath}/pictures' ; }", "ln -snvf '{$dataPath}/pictures' 'pictures'", "{ [ -d '{$dataPath}/test/assets' ] || mkdir -p '{$dataPath}/test/assets' ; }", "ln -snvf '../{$dataPath}/test/assets' 'test/assets'"); $options = array('applicationRootDirectory' => 'app/dir/', 'directories' => array('pictures', 'test/assets')); $this->shellMock->expects($this->once())->method('executeOrSimulate')->with($expectedCommands, $this->nodeMock, $this->deploymentMock); $this->task->execute($this->nodeMock, $this->applicationMock, $this->deploymentMock, $options); }
/** * 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()) { // Actions: // * 1 = ACTION_UPDATE_CLEAR_TABLE // * 2 = ACTION_UPDATE_ADD // * 3 = ACTION_UPDATE_CHANGE // * 4 = ACTION_UPDATE_CREATE_TABLE // 5 = ACTION_REMOVE_CHANGE // 6 = ACTION_REMOVE_DROP // 7 = ACTION_REMOVE_CHANGE_TABLE // 8 = ACTION_REMOVE_DROP_TABLE $actions = !empty($options['updateDatabaseActions']) ? $options['updateDatabaseActions'] : '1,2,3,4'; $commands = $this->buildCommands($deployment, $application, 'coreapi', 'databaseapi:databasecompare ' . escapeshellarg($actions), $options); if (count($commands) > 0) { $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); $applicationRootDirectory = isset($options['applicationRootDirectory']) ? trim($options['applicationRootDirectory'], '/') : ''; $workingDirectory = escapeshellarg(Files::concatenatePaths(array($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 ./web/fileadmin", "ln -sf {$relativeDataPath}/uploads ./web/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 -snvf ' . 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 * @throws TaskExecutionException * @return void */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { if ($node->isLocalhost()) { $deployment->getLogger()->log('node seems not to be a remote node', LOG_DEBUG); } else { $username = $node->hasOption('username') ? $node->getOption('username') : NULL; if (!empty($username)) { $username = $username . '@'; } $hostname = $node->getHostname(); $sshOptions = array('-A', '-q', '-o BatchMode=yes'); if ($node->hasOption('port')) { $sshOptions[] = '-p ' . escapeshellarg($node->getOption('port')); } $command = 'ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . ' exit;'; $this->shell->execute($command, $deployment->getNode('localhost'), $deployment); $deployment->getLogger()->log('SSH connection successfully established', LOG_DEBUG); } }
/** * @param string $command */ protected function flowRemoteCommand($command) { $cmd = array(); $context = $this->getRemoteContext(); if ($context) { $cmd[] = 'FLOW_CONTEXT=' . $context; } $cmd[] = $this->getRemoteRootPath() . 'flow ' . $command; $this->shell->executeOrSimulate(implode(' ', $cmd), $this->remoteNode, $this->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 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 (!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); }
/** * Checks if a given file exists. * * @param string $pathAndFileName * @param Node $node * @param CMS $application * @param Deployment $deployment * @param array $options * @return boolean */ protected function fileExists($pathAndFileName, Node $node, CMS $application, Deployment $deployment, array $options = array()) { $this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options); $pathAndFileName = Files::concatenatePaths(array($this->workingDirectory, $pathAndFileName)); return $this->shell->executeOrSimulate('test -f ' . escapeshellarg($pathAndFileName), $this->targetNode, $deployment, TRUE) === FALSE ? FALSE : TRUE; }
public function copy($source, $destination) { $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->executeOrSimulate(array('scp ' . $source . ' ' . $this->username . '@' . $this->hostname . ':' . $destination), $localhost, $this->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()) { $targetPath = $deployment->getApplicationReleasePath($application); $this->shell->executeOrSimulate('cd ' . $targetPath . ' && FLOW_CONTEXT=' . $options['context'] . ' ./flow typo3.flow:cache:warmup', $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()) { $commands = array('if [ -d ' . escapeshellarg($deployment->getApplicationReleasePath($application)) . ' ]; then ' . 'cd ' . escapeshellarg($deployment->getApplicationReleasePath($application)) . '; ' . 'if [ -d \'.git\' ] && hash git 2>/dev/null; then ' . 'CHANGES=$( git status --porcelain ); ' . 'if [ "$CHANGES" ]; then ' . 'echo \'Detected changes in the target directory. Deployments are just possible to clean targets!\' 1>&2; ' . 'echo $CHANGES 1>&2; ' . 'exit 1; ' . 'fi; ' . 'fi; ' . 'fi;'); $this->shell->executeOrSimulate($commands, $node, $deployment); }