/** * 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); }
/** * 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 * * 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 * @throws \TYPO3\Surf\Exception\InvalidConfigurationException * @return void */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $this->assertRequiredOptionsExist($options); $dumpCommand = new ProcessBuilder(); $dumpCommand->setPrefix('mysqldump'); $dumpCommand->setArguments(array('-h', $options['sourceHost'], '-u', $options['sourceUser'], '-p' . $options['sourcePassword'], $options['sourceDatabase'])); $mysqlCommand = new ProcessBuilder(); $mysqlCommand->setPrefix('mysql'); $mysqlCommand->setArguments(array('-h', $options['targetHost'], '-u', $options['targetUser'], '-p' . $options['targetPassword'], $options['targetDatabase'])); $arguments = array(); $username = isset($options['username']) ? $options['username'] . '@' : ''; $hostname = $node->getHostname(); $arguments[] = $username . $hostname; if ($node->hasOption('port')) { $arguments[] = '-P'; $arguments[] = $node->getOption('port'); } $arguments[] = $mysqlCommand->getProcess()->getCommandLine(); $sshCommand = new ProcessBuilder(); $sshCommand->setPrefix('ssh'); $sshCommand->setArguments($arguments); $command = $dumpCommand->getProcess()->getCommandLine() . ' | ' . $sshCommand->getProcess()->getCommandLine(); $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->executeOrSimulate($command, $localhost, $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()) { $localPackagePath = $deployment->getWorkspacePath($application); $releasePath = $deployment->getApplicationReleasePath($application); $remotePath = $application->getDeploymentPath() . '/cache/transfer'; // make sure there is a remote .cache folder $command = 'mkdir -p ' . $remotePath; $this->shell->executeOrSimulate($command, $node, $deployment); $username = $node->hasOption('username') ? $node->getOption('username') . '@' : ''; $hostname = $node->getHostname(); $port = $node->hasOption('port') ? ' -p ' . escapeshellarg($node->getOption('port')) : ''; $key = $node->hasOption('privateKeyFile') ? ' -i ' . escapeshellarg($node->getOption('privateKeyFile')) : ''; $quietFlag = isset($options['verbose']) && $options['verbose'] ? '' : '-q'; $rshFlag = $node->isLocalhost() ? '' : '--rsh="ssh' . $port . $key . '" '; $rsyncFlags = isset($options['rsyncFlags']) ? $options['rsyncFlags'] : "--recursive --times --perms --links --delete --delete-excluded --exclude '.git'"; $destinationArgument = $node->isLocalhost() ? $remotePath : "{$username}{$hostname}:{$remotePath}"; $command = "rsync {$quietFlag} --compress {$rshFlag} {$rsyncFlags} " . escapeshellarg($localPackagePath . '/.') . ' ' . escapeshellarg($destinationArgument); if ($node->hasOption('password')) { $resourcesPath = realpath(__DIR__ . '/../../../Resources'); $passwordSshLoginScriptPathAndFilename = $resourcesPath . '/Private/Scripts/PasswordSshLogin.expect'; $command = sprintf('expect %s %s %s', escapeshellarg($passwordSshLoginScriptPathAndFilename), escapeshellarg($node->getOption('password')), $command); } $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->executeOrSimulate($command, $localhost, $deployment); $command = strtr("cp -RPp {$remotePath}/. {$releasePath}", "\t\n", ' '); // TODO Copy revision file (if it exists) for application to deployment path with release identifier $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); }
/** * 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 Supported options: "scriptBasePath" and "scriptIdentifier" * @return void * @throws \TYPO3\Surf\Exception\InvalidConfigurationException * @throws \TYPO3\Surf\Exception\TaskExecutionException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $workspacePath = $deployment->getWorkspacePath($application); $scriptBasePath = isset($options['scriptBasePath']) ? $options['scriptBasePath'] : Files::concatenatePaths(array($workspacePath, 'Web')); if (!isset($options['scriptIdentifier'])) { // Generate random identifier $factory = new \RandomLib\Factory(); $generator = $factory->getMediumStrengthGenerator(); $scriptIdentifier = $generator->generateString(32, \RandomLib\Generator::CHAR_ALNUM); // Store the script identifier as an application option $application->setOption('TYPO3\\Surf\\Task\\Php\\WebOpcacheResetExecuteTask[scriptIdentifier]', $scriptIdentifier); } else { $scriptIdentifier = $options['scriptIdentifier']; } $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $commands = array('cd ' . escapeshellarg($scriptBasePath), 'rm -f surf-opcache-reset-*'); $this->shell->executeOrSimulate($commands, $localhost, $deployment); if (!$deployment->isDryRun()) { $scriptFilename = $scriptBasePath . '/surf-opcache-reset-' . $scriptIdentifier . '.php'; $result = file_put_contents($scriptFilename, '<?php if (function_exists("opcache_reset")) { opcache_reset(); } @unlink(__FILE__); echo "success"; '); if ($result === false) { throw new \TYPO3\Surf\Exception\TaskExecutionException('Could not write file "' . $scriptFilename . '"', 1421932414); } } }
/** * Set up test dependencies * * This sets up a stubbed shell command service to record command executions * and return predefined command responses. */ protected function setUp() { $this->commands = array('executed' => array()); $commands =& $this->commands; $this->responses = array(); $responses =& $this->responses; /** @var \TYPO3\Surf\Domain\Service\ShellCommandService|\PHPUnit_Framework_MockObject_MockObject $shellCommandService */ $shellCommandService = $this->getMock('TYPO3\\Surf\\Domain\\Service\\ShellCommandService'); $shellCommandService->expects($this->any())->method('execute')->will($this->returnCallback(function ($command) use(&$commands, &$responses) { if (is_array($command)) { $commands['executed'] = array_merge($commands['executed'], $command); } else { $commands['executed'][] = $command; if (isset($responses[$command])) { return $responses[$command]; } } return ''; })); $shellCommandService->expects($this->any())->method('executeOrSimulate')->will($this->returnCallback(function ($command) use(&$commands, $responses) { if (is_array($command)) { $commands['executed'] = array_merge($commands['executed'], $command); } else { $commands['executed'][] = $command; if (isset($responses[$command])) { return $responses[$command]; } } return ''; })); $this->task = $this->createTask(); if ($this->task instanceof ShellCommandServiceAwareInterface) { $this->task->setShellCommandService($shellCommandService); } $this->node = new \TYPO3\Surf\Domain\Model\Node('TestNode'); $this->node->setHostname('hostname'); $this->deployment = new \TYPO3\Surf\Domain\Model\Deployment('TestDeployment'); /** @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject $mockLogger */ $mockLogger = $this->getMock('Psr\\Log\\LoggerInterface'); $this->deployment->setLogger($mockLogger); $this->deployment->setWorkspacesBasePath('./Data/Surf'); $this->application = new \TYPO3\Surf\Domain\Model\Application('TestApplication'); $this->deployment->initialize(); }
/** * 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); }
/** * 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()) { $replacePaths = array(); $replacePaths['{workspacePath}'] = escapeshellarg($deployment->getWorkspacePath($application)); if (!isset($options['rollbackCommand'])) { return; } $command = $options['rollbackCommand']; $command = str_replace(array_keys($replacePaths), $replacePaths, $command); $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->execute($command, $localhost, $deployment, true); }
<?php use TYPO3\Surf\Domain\Model\Workflow; use TYPO3\Surf\Domain\Model\Node; use TYPO3\Surf\Domain\Model\SimpleWorkflow; $application = new \Famelo\Surf\SharedHosting\Application\Flow(); $application->setOption('repositoryUrl', '{repositoryUrl}'); $application->setDeploymentPath('{directory}'); $application->setOption('keepReleases', 3); $application->setOption('defaultContext', 'Production'); $application->setOption('composerCommandPath', '/html/composer.phar'); $application->setHosting('Mittwald'); $application->setOption('transferMethod', 'rsync'); $application->setOption('packageMethod', 'git'); $application->setOption('updateMethod', NULL); $deployment->addApplication($application); $workflow = new SimpleWorkflow(); $workflow->setEnableRollback(FALSE); $workflow->afterTask('typo3.surf:typo3:flow:copyconfiguration', array('famelo.surf.sharedhosting:downloadbeard', 'famelo.surf.sharedhosting:beardpatch'), $application); $deployment->setWorkflow($workflow); $node = new Node('{host}'); $node->setHostname('{host}'); $node->setOption('username', '{user}'); $application->addNode($node); $deployment->addApplication($application);
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); }
$application->setDeploymentPath(getenv('DEPLOYMENT_PATH')); } else { throw new \Exception('Deployment path must be set in the DEPLOYMENT_PATH env variable.'); } $application->setOption('repositoryUrl', 'git://git.typo3.org/Sites/NeosTypo3Org.git'); $application->setOption('sitePackageKey', 'TYPO3.NeosTypo3Org'); $application->setOption('keepReleases', 50); $application->setOption('composerCommandPath', 'php /var/www/vhosts/neos.typo3.org/home/composer.phar'); $deployment->addApplication($application); $workflow = new SimpleWorkflow(); # $workflow->setEnableRollback(FALSE); $deployment->setWorkflow($workflow); $deployment->onInitialize(function () use($workflow, $application) { $workflow->removeTask('typo3.surf:flow3:setfilepermissions'); $workflow->removeTask('typo3.surf:flow3:copyconfiguration'); $workflow->removeTask('typo3.surf:typo3:importsite'); }); #$workflow->afterTask('typo3.surf:symlinkrelease', array('typo3.surf:varnishpurge'), $application); if (getenv('DEPLOYMENT_HOST')) { $hostName = getenv('DEPLOYMENT_HOST'); } else { throw new \Exception('Deployment host name must be set in the DEPLOYMENT_HOST env variable.'); } $node = new Node($hostName); $node->setHostname($hostName); if (getenv('DEPLOYMENT_USERNAME')) { $node->setOption('username', getenv('DEPLOYMENT_USERNAME')); } else { throw new \Exception('Username must be set in the DEPLOYMENT_USERNAME env variable.'); } $application->addNode($node);
/** * @return void */ protected function setLocalNode() { $this->localNode = new Node('localhost'); $this->localNode->setHostname('localhost'); }
$application->setOption('packageMethod', 'git'); $application->setOption('updateMethod', NULL); $application->setContext('Production'); $application->setDeploymentPath('/home/hostroot/sites/langeland/iotdemo'); $application->setOption('keepReleases', 2); $deployment->addApplication($application); $workflow = new SimpleWorkflow(); $workflow->setEnableRollback(TRUE); // Prevent local Settings.yaml from being transferred $workflow->defineTask('typo3.surf:shell:removeLocalConfiguration', 'typo3.surf:shell', array('command' => 'cd "{releasePath}" && rm -f Configuration/Settings.yaml')); $workflow->beforeStage('migrate', array('typo3.surf:shell:removeLocalConfiguration'), $application); // Remove resource links since they're absolute symlinks to previous releases (will be generated again automatically) $workflow->defineTask('typo3.surf:shell:unsetResourceLinks', 'typo3.surf:shell', array('command' => 'cd {releasePath} && rm -rf Web/_Resources/Persistent/*(N)')); $workflow->beforeStage('switch', array('typo3.surf:shell:unsetResourceLinks'), $application); $workflow->afterStage('switch', 'typo3.surf:typo3:flow:publishresources', $application); // Clear PHP 5.5+ OpCache (required for php-fpm) //$resetScriptFilename = 'surf-opcache-reset-' . uniqid() . '.php'; //$workflow->defineTask('fn:clearopcache', // 'typo3.surf:shell', // array('command' => 'cd {currentPath}/Web && echo "<?php if (function_exists(\"opcache_reset\")) { opcache_reset(); } @unlink(__FILE__); echo \"cache cleared\";" > ' . $resetScriptFilename . ' && curl -s "http://kmcpr-live.lombard.pil.dk/' . $resetScriptFilename . '" && rm -rf ' . $resetScriptFilename) //); //$workflow->afterStage('switch', array('fn:clearopcache'), $application); $deployment->setWorkflow($workflow); $deployment->onInitialize(function () use($workflow, $application) { $workflow->setTaskOptions('typo3.surf:generic:createDirectories', array('directories' => array('shared/Data/Web/_Resources', 'shared/Data/Session'))); $workflow->setTaskOptions('typo3.surf:generic:createSymlinks', array('symlinks' => array('Web/_Resources' => '../../../shared/Data/Web/_Resources/', 'Data/Session' => '../../../shared/Data/Session/'))); }); $node = new Node('Flab'); $node->setHostname('ny.flab.dk'); $node->setOption('username', 'langeland'); $application->addNode($node);
/** * Get a node by name * * In the special case "localhost" an ad-hoc Node with hostname "localhost" is returned. * * @return \TYPO3\Surf\Domain\Model\Node The Node or NULL if no Node with the given name was found */ public function getNode($name) { if ($name === 'localhost') { $node = new Node('localhost'); $node->setHostname('localhost'); return $node; } $nodes = $this->getNodes(); return isset($nodes[$name]) ? $nodes[$name] : null; }
$application->setOption('createTags', getenv('CREATE_TAGS') !== 'false'); $application->setOption('pushTags', getenv('PUSH_TAGS') === 'true'); if (getenv('SOURCEFORGE_USER') && getenv('ENABLE_SOURCEFORGE_UPLOAD') === 'true') { $application->setOption('enableSourceforgeUpload', TRUE); $application->setOption('sourceforgeUserName', getenv('SOURCEFORGE_USER')); } if (getenv('RELEASE_HOST')) { $application->setOption('releaseHost', getenv('RELEASE_HOST')); $application->setOption('releaseHostLogin', getenv('RELEASE_HOST_LOGIN')); $application->setOption('releaseHostSitePath', getenv('RELEASE_HOST_SITE_PATH')); } if (getenv('WORKSPACE')) { $application->setDeploymentPath(getenv('WORKSPACE')); } else { throw new \Exception('Deployment path must be set in the WORKSPACE env variable'); } $deployment->addApplication($application); $workflow = new SimpleWorkflow(); $deployment->setWorkflow($workflow); // Remove the setfilepermissions task because Surf doesn't use sudo ... // And we do not need any data or configuration in the release archives ... $deployment->onInitialize(function () use($workflow, $application) { $workflow->removeTask('typo3.surf:flow:setfilepermissions'); $workflow->removeTask('typo3.surf:flow:symlinkdata'); $workflow->removeTask('typo3.surf:flow:symlinkconfiguration'); $workflow->removeTask('typo3.surf:flow:copyconfiguration'); }); $workflow->setEnableRollback(FALSE); $node = new Node('localhost'); $node->setHostname('localhost'); $application->addNode($node);
/** @var \TYPO3\Surf\Domain\Model\Deployment $deployment */ use TYPO3\Surf\Domain\Model\Node; use TYPO3\Surf\Domain\Model\SimpleWorkflow; $projectName = 'PROJECTNAME - Dev'; $deploymentPath = '/path/to/deploy'; $deploymentHost = 'PROJECTID-dev'; $repositoryUrl = 'PROJECTREPOURL'; $repositoryBranch = getenv('DEPLOY_BRANCH') ?: 'master'; $composerCommandPath = 'composer'; // Set this, if on remote host the correct PHP binary is not available in PATH //$deployment->setOption('phpBinaryPathAndFilename', '/usr/local/bin/php5-56LATEST-CLI'); // No changes are required in the default case below this point. $application = new \TYPO3\Surf\Application\TYPO3\CMS(); $deployment->addApplication($application); $node = new Node($deploymentHost); $node->setHostname($deploymentHost); $application->addNode($node); $application->setOption('projectName', $projectName); $application->setOption('repositoryUrl', $repositoryUrl); $application->setOption('branch', $repositoryBranch); $application->setDeploymentPath($deploymentPath); $application->setOption('keepReleases', 1); $application->setOption('TYPO3\\Surf\\Task\\TYPO3\\CMS\\SymlinkDataTask[applicationRootDirectory]', 'web'); $application->setOption('TYPO3\\Surf\\Task\\Transfer\\RsyncTask[rsyncExcludes]', array('.git', 'web/fileadmin', 'web/uploads')); $application->setOption('applicationWebDirectory', 'web'); $application->setOption('composerCommandPath', $composerCommandPath); // Not sure if we really need this or not //$application->setOption('TYPO3\\Surf\\Task\\Package\\GitTask[hardClean]', true); $application->setContext('Production'); $deployment->onInitialize(function () use($deployment) { /** @var SimpleWorkflow $workflow */