@param Node        $node
@param Application $application
@param Deployment  $deployment
@param array       $options

@throws InvalidConfigurationException
@throws TaskExecutionException
177354
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        // Get nodes
        if (empty($options['sourceNode']) || !is_array($options['sourceNode'])) {
            throw new InvalidConfigurationException('No sourceNode given in options.', 1409078366);
        }
        $sourceNode = $this->nodeFactory->getNodeByArray($options['sourceNode']);
        $localNode = $deployment->getNode('localhost');
        $targetNode = $node;

        // Get shared paths
        $sourceSharedPath = $this->getSharedPathFromNode(
            $sourceNode,
            $deployment,
            $options['sourceNodeOptions'],
            $application
        );
        $localSharedPath = $deployment->getWorkspacePath($application).'_shared/';
        $targetSharedPath = $this->getSharedPathFromNode($node, $deployment, $options, $application);

        // maybe we should change this behaviour ...
        if ($targetNode->isLocalhost() === true || $sourceNode->isLocalhost() === true) {
            // sync direct
            $this->sync($sourceNode, $sourceSharedPath, $targetNode, $targetSharedPath, $deployment, $options);
        } else {
            // cached
            $this->sync($sourceNode, $sourceSharedPath, $localNode, $localSharedPath, $deployment, $options);
            $this->sync($localNode, $localSharedPath, $targetNode, $targetSharedPath, $deployment, $options);
        }
    }
745251
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $deployment->getLogger()->warning(DeprecationMessageFactory::createGenericDeprecationWarningForTask(__CLASS__));
        $options = $this->configureOptions($options);
        $projectName = $options['sourceforgeProjectName'];

        $sourceforgeLogin = $options['sourceforgeUserName'] . ',' . $options['sourceforgeProjectName'];

        $projectDirectory = str_replace(' ', '\ ', sprintf('/home/frs/project/%s/%s/%s/%s/%s', substr($projectName, 0, 1), substr($projectName, 0, 2), $projectName, $options['sourceforgePackageName'], $options['version']));
        $targetHostAndDirectory = escapeshellarg($sourceforgeLogin . '@frs.sourceforge.net:' . $projectDirectory);

        $this->shell->executeOrSimulate('rsync -e ssh ' . implode(' ', $options['files']) . ' ' . $targetHostAndDirectory, $node, $deployment);
    }
593619
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $options = $this->configureOptions($options);
        $targetReleasePath = $deployment->getApplicationReleasePath($application);
        $webDirectory = $options['webDirectory'];
        $relativeDataPath = $relativeDataPathFromWeb = '../../shared/Data';
        if ($webDirectory !== '') {
            $relativeDataPathFromWeb = str_repeat('../', substr_count(trim($webDirectory, '/'), '/') + 1) . $relativeDataPath;
        }
        $absoluteWebDirectory = rtrim("$targetReleasePath/$webDirectory", '/');

        $commands[] = 'cd ' . escapeshellarg($targetReleasePath);

        foreach ($options['symlinkDataFolders'] as $directory) {
            $commands[] = sprintf('{ [ -d %1$s ] || mkdir -p %1$s; }', escapeshellarg($relativeDataPath . '/' . $directory));
            $commands[] = sprintf('ln -sf %1$s %2$s', escapeshellarg($relativeDataPathFromWeb . '/' . $directory), escapeshellarg($absoluteWebDirectory . '/' . $directory));
        }

        foreach ($options['directories'] as $directory) {
            $directory = trim($directory, '\\/');
            $targetDirectory = Files::concatenatePaths([$relativeDataPath, $directory]);
            $commands[] = sprintf('{ [ -d %1$s ] || mkdir -p %1$s; }', escapeshellarg($targetDirectory));
            $commands[] = sprintf('ln -sf %1$s %2$s', escapeshellarg(str_repeat('../', substr_count(trim($directory, '/'), '/')) . $targetDirectory), escapeshellarg($directory));
        }
        $this->shell->executeOrSimulate($commands, $node, $deployment);
    }
199801
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        if (!isset($options['rollbackCommand'])) {
            return;
        }

        $replacePaths = [
            '{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);
    }
256652
public static synchronized void deployment(Class<?> deployment) {
		Preconditions.checkArgument(deployment != null, 
				"Parameter 'deployment' must not be [" + deployment + "]");
		Preconditions.checkArgument(deployment.getAnnotation(Deployment.class) != null,
				"'deployment' [" + deployment + "] must be annotated with @Deployment");
		Jaguar.deployment = deployment;
		logger.info("Deployment has been set to [" + deployment.getSimpleName() + "]");
	}
337778
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        Assert::isInstanceOf($application, Flow::class, sprintf('Flow application needed for PublishResourcesTask, got "%s"', get_class($application)));

        if ($application->getVersion() >= '3.0') {
            $targetPath = $deployment->getApplicationReleasePath($application);
            $this->shell->executeOrSimulate($application->buildCommand($targetPath, 'resource:publish'), $node, $deployment);
        }
    }
1248917
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $localPackagePath = $deployment->getWorkspacePath($application);
        $releasePath = $deployment->getApplicationReleasePath($application);

        $remotePath = Files::concatenatePaths([$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();
        $noPubkeyAuthentication = $node->hasOption('password') ? ' -o PubkeyAuthentication=no' : '';
        $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' . $noPubkeyAuthentication . $port . $key . '" ');

        $rsyncExcludes = isset($options['rsyncExcludes']) ? $options['rsyncExcludes'] : ['.git'];
        $excludeFlags = $this->getExcludeFlags($rsyncExcludes);

        $rsyncFlags = (isset($options['rsyncFlags']) ? $options['rsyncFlags'] : '--recursive --times --perms --links --delete --delete-excluded') . $excludeFlags;

        $destinationArgument = ($node->isLocalhost() ? $remotePath : "{$username}{$hostname}:{$remotePath}");

        $command = "rsync {$quietFlag} --compress {$rshFlag} {$rsyncFlags} " . escapeshellarg($localPackagePath . '/.') . ' ' . escapeshellarg($destinationArgument);

        if ($node->hasOption('password')) {
            $passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([dirname(dirname(dirname(__DIR__))), 'Resources', 'Private/Scripts/PasswordSshLogin.expect']);
            if (Phar::running() !== '') {
                $passwordSshLoginScriptContents = file_get_contents($passwordSshLoginScriptPathAndFilename);
                $passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([$deployment->getTemporaryPath(), 'PasswordSshLogin.expect']);
                file_put_contents($passwordSshLoginScriptPathAndFilename, $passwordSshLoginScriptContents);
            }
            $command = sprintf('expect %s %s %s', escapeshellarg($passwordSshLoginScriptPathAndFilename), escapeshellarg($node->getOption('password')), $command);
        }

        $localhost = new Node('localhost');
        $localhost->onLocalhost();
        $this->shell->executeOrSimulate($command, $localhost, $deployment);

        if (isset($passwordSshLoginScriptPathAndFilename) && Phar::running() !== '') {
            unlink($passwordSshLoginScriptPathAndFilename);
        }

        $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);
    }
1294422
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        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);
    }
1112676
public function deploy($options = [
    'branch' => InputOption::VALUE_REQUIRED,
    'tag' => InputOption::VALUE_REQUIRED,
    'commit-msg' => InputOption::VALUE_REQUIRED,
    'ignore-dirty' => FALSE,
    'dry-run' => FALSE,
    'ignore-platform-reqs' => FALSE,
  ]) {
    if ($options['dry-run']) {
      $this->logger->warning("This will be a dry run, the artifact will not be pushed.");
    }
    $this->checkDirty($options);

    if (isset($options['ignore-platform-reqs'])) {
      $this->ignorePlatformReqs = $options['ignore-platform-reqs'];
    }

    if (!$options['tag'] && !$options['branch']) {
      $this->createTag = $this->confirm("Would you like to create a tag?", $this->createTag);
    }
    $this->commitMessage = $this->getCommitMessage($options);

    if ($options['tag'] || $this->createTag) {
      // Warn if they're creating a tag and we won't tag the source for them.
      if (!$this->tagSource) {
        $this->say("Config option deploy.tag_source if FALSE. The source repo will not be tagged.");
      }
      $this->deployToTag($options);
    }
    else {
      $this->deployToBranch($options);
    }
  }
12668
private void deployModule(final Node node, final InstanceContext instance, final CountingCompletionHandler<Void> counter) {
    log.debug(String.format("%s - Deploying %s to %s", NetworkManager.this, instance.component().asModule().module(), node.address()));
    node.deployModule(instance.component().asModule().module(), Components.buildConfig(instance, cluster), 1, new Handler<AsyncResult<String>>() {
      @Override
      public void handle(AsyncResult<String> result) {
        if (result.failed()) {
          counter.fail(result.cause());
        } else {
          deploymentIDs.put(instance.address(), result.result(), new Handler<AsyncResult<String>>() {
            @Override
            public void handle(AsyncResult<String> result) {
              counter.succeed();
            }
          });
        }
      }
    });
  }
918758
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $sourceNode = $this->nodeFactory->getNodeByArray($options['sourceNode']);
        $credentials = $this->getCredentials($sourceNode, $deployment, $options['sourceNodeOptions'], $application);
        $dumpFile = $this->getDumpFile($options['sourceNodeOptions'], $credentials);
        $source = $this->getArgument($sourceNode, $dumpFile);

        $credentials = $this->getCredentials($node, $deployment, $options, $application);
        $dumpFile = $this->getDumpFile($options, $credentials);
        $target = $this->getArgument($node, $dumpFile);

        $command = 'scp -o BatchMode=\'yes\' '.$source.' '.$target;
        if ($sourceNode->isLocalhost() === true) {
            $this->shell->executeOrSimulate($command, $sourceNode, $deployment);
        } else {
            $this->shell->executeOrSimulate($command, $node, $deployment);
        }
    }
350021
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $this->ensureApplicationIsTypo3Cms($application);

        $options = $this->configureOptions($options);

        $arguments = array_merge([$this->getConsoleScriptFileName($node, $application, $deployment, $options), $options['command']], $options['arguments']);

        $this->executeCliCommand(
            $arguments,
            $node,
            $application,
            $deployment,
            $options
        );
    }
485293
public function process(NodeType $nodeType, array &$configuration, array $options)
    {
        $pluginViewDefinitions = $this->pluginService->getPluginViewDefinitionsByPluginNodeType($nodeType);
        if ($pluginViewDefinitions === []) {
            return;
        }
        $configuration['ui']['inspector']['groups']['pluginViews'] = [
            'position' => '9999',
            'label' => 'Plugin Views'
        ];
        $configuration['properties']['views'] = [
            'type' => 'string',
            'ui' => [
                'inspector' => [
                    'group' => 'pluginViews',
                    'position' => '20',
                    'editor' => 'Neos.Neos/Inspector/Editors/PluginViewsEditor'
                ]
            ]
        ];
    }
1337852
protected function getCredentialsFromTypo3Cms(
        Node $node,
        Deployment $deployment,
        array $options,
        Application $application
    )
    {
        $commands = $this->buildCommands($deployment, $application, $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);
        }

        // Compatibility with TYPO3 v8
        if (!empty($returnedOutput['Connections'])) {
            $returnedOutput = $returnedOutput['Connections']['Default'];
        }

        $credentials = [];
        foreach ($returnedOutput as $key => $value) {
            switch ($key) {
                case 'username':
                    $credentials['user'] = $value;
                    break;
                case 'dbname':
                    $credentials['database'] = $value;
                    break;
                default:
                    $credentials[$key] = $value;
                    break;
            }
        }

        return $credentials;
    }
1306681
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $options = $this->configureOptions($options);

        $workspacePath = $deployment->getWorkspacePath($application);
        $webDirectory = $application->hasOption('webDirectory') ? $application->getOption('webDirectory') : 'Web';
        $scriptBasePath = $options['scriptBasePath'] ?: Files::concatenatePaths([$workspacePath, $webDirectory]);

        if ($options['scriptIdentifier'] === null) {
            // Store the script identifier as an application option
            $scriptIdentifier = bin2hex($this->randomBytesGenerator->generate(32));
            $application->setOption(WebOpcacheResetExecuteTask::class . '[scriptIdentifier]', $scriptIdentifier);
        } else {
            $scriptIdentifier = $options['scriptIdentifier'];
        }

        $localhost = new Node('localhost');
        $localhost->onLocalhost();

        $commands = [
            'cd ' . escapeshellarg($scriptBasePath),
            'rm -f surf-opcache-reset-*',
        ];

        $this->shell->executeOrSimulate($commands, $localhost, $deployment);

        if (! $deployment->isDryRun()) {
            $scriptFilename = sprintf('%s/surf-opcache-reset-%s.php', $scriptBasePath, $scriptIdentifier);

            $result = $this->filesystem->put($scriptFilename, '<?php
                if (function_exists("opcache_reset")) {
                    opcache_reset();
                }
                @unlink(__FILE__);
                echo "success";
            ');

            if ($result === false) {
                throw TaskExecutionException::webOpcacheResetCreateScriptTaskCouldNotWritFile($scriptFilename);
            }
        }
    }
411267
@Override
    public void deploy(InputStream inputStream) throws IOException {
        final List<? extends HasMetadata> entities = deploy("application", inputStream);

        if (this.applicationName == null) {

            Optional<String> deploymentConfig = entities.stream()
                .filter(hm -> hm instanceof DeploymentConfig)
                .map(hm -> (DeploymentConfig) hm)
                .map(dc -> dc.getMetadata().getName()).findFirst();

            deploymentConfig.ifPresent(name -> this.applicationName = name);
        }
    }
32181
protected function directoryExists($directory, Node $node, CMS $application, Deployment $deployment, array $options = [])
    {
        $this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
        $directory = Files::concatenatePaths([$this->workingDirectory, $directory]);
        return $this->shell->executeOrSimulate('test -d ' . escapeshellarg($directory), $this->targetNode, $deployment, true) === false ? false : true;
    }