Execute this task

@param \TYPO3\Surf\Domain\Model\Node $node
@param CMS|\TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options

@throws InvalidConfigurationException
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
        );
    }
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);
        }
    }
928007
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $this->removeFile(
            rtrim($application->getReleasesPath(), '/').'/'.$this->getTargetPath($options),
            $node,
            $deployment,
            $options
        );

        $this->removeFile(
            rtrim($deployment->getWorkspacePath($application), '/').'/'.$this->getTargetPath($options),
            $deployment->getNode('localhost'),
            $deployment,
            $options
        );
    }
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);
        }
    }
568283
public static function configure($object, array $options): void
    {
        foreach ($options as $property => $value) {
            if (\property_exists($object, $property)) {
                $object->$property = $value;
            }
        }
    }
262030
@TaskAction
  public void deployAllAction() throws AppEngineException {
    List<Path> deployables = new ArrayList<>();

    // Look for app.yaml
    Path appYaml = stageDirectory.toPath().resolve("app.yaml");
    if (!Files.isRegularFile(appYaml)) {
      throw new GradleException("Failed to deploy all: app.yaml not found.");
    }
    addDeployable(deployables, appYaml);

    // Look for configuration yamls
    String[] validYamls = {"cron.yaml", "dispatch.yaml", "dos.yaml", "index.yaml", "queue.yaml"};
    for (String yamlName : validYamls) {
      Path yaml = deployExtension.getAppEngineDirectory().toPath().resolve(yamlName);
      if (Files.isRegularFile(yaml)) {
        addDeployable(deployables, yaml);
      }
    }

    // Deploy
    Deployment deploy = gcloud.newDeployment(CloudSdkOperations.getDefaultHandler(getLogger()));

    DeployConfiguration deployConfig = deployExtension.toDeployConfiguration(deployables);
    deploy.deploy(deployConfig);
  }
1109077
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        try {
            $commands = $this->buildCommands(
                $deployment,
                $application,
                $options
            );
            $this->shell->executeOrSimulate($commands, $node, $deployment);
        } catch (CommandProviderException $e) {
            $deployment->getLogger()->log('Task was skipped! Reason: ' . $e->getMessage(), LOG_WARNING);
        }
    }
607268
protected function determineWorkingDirectoryAndTargetNode(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        if (!isset($this->workingDirectory, $this->targetNode)) {
            if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) {
                $this->workingDirectory = $deployment->getWorkspacePath($application);
                $node = $deployment->getNode('localhost');
            } else {
                $this->workingDirectory = $deployment->getApplicationReleasePath($application);
            }
            $this->targetNode = $node;
        }
    }
852477
public void deploy() throws MojoExecutionException {
    stager.stage();

    DeployConfiguration config =
        configBuilder.buildDeployConfiguration(ImmutableList.of(deployMojo.getStagingDirectory()));

    try {
      deployMojo.getAppEngineFactory().deployment().deploy(config);
    } catch (AppEngineException ex) {
      throw new MojoExecutionException("App Engine application deployment failed", ex);
    }
  }
1085654
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $unLockDeployment = new UnlockDeploymentTask();
        $unLockDeployment->setShellCommandService(new ShellCommandService());
        $unLockDeployment->execute($node, $application, $deployment, $options);
    }
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;
    }
872304
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $targetPath = $deployment->getApplicationReleasePath($application);
        $this->shell->executeOrSimulate(
            'cd '.$targetPath.' && FLOW_CONTEXT='.$options['context'].' ./flow typo3.flow:cache:flush',
            $node,
            $deployment
        );
    }
1332404
public function export(NodeInterface $node, array $options = [])
    {
        $options = array_replace_recursive(
            [
                'writer'            => 'graphviz'
            ],
            $options
        );

        if (is_string($options['writer'])) {
            switch ($options['writer']) {
                case 'graphviz':
                    $options['path'] = $options['path'] ?? $this->generateRandomFilePath();
                    $options['writer'] = new GraphvizWriter();

                    break;
                default:
                    throw InvalidWriterTypeException::create($options['writer']);
            }
        }

        $config = new Config(
            [
                'node'              => $node
            ],
            [
                'writer'            => $options['writer']
            ]
        );

        $config->save(
            [
                'writerOptions'        => $options
            ]
        );

        $response = new Response();

        $response->setPath($options['path']);

        return $response;
    }
365939
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        try {
            $options = $this->configureOptions($options);
        } catch (ExceptionInterface $e) {
            return;
        }

        if (empty($options['directories'])) {
            return;
        }

        $baseDirectory = $options['baseDirectory'] ?: $deployment->getApplicationReleasePath($application);

        $commands = array_map(function ($directory) {
            return sprintf('mkdir -p %s', $directory);
        }, $options['directories']);

        array_unshift($commands, sprintf('cd %s', $baseDirectory));

        $this->shell->executeOrSimulate($commands, $node, $deployment);
    }
131423
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $configurationPath = $input->getOption('configurationPath');
        $deploymentNames = $this->factory->getDeploymentNames($configurationPath);

        $output->writeln(sprintf(PHP_EOL . '<u>Deployments in "%s":</u>' . PHP_EOL, $this->factory->getDeploymentsBasePath($configurationPath)));
        foreach ($deploymentNames as $deploymentName) {
            $line = sprintf('  <info>%s</info>', $deploymentName);
            $output->writeln($line);
        }
        $output->writeln('');
    }
567498
protected function validateOutput($stepActionParams, $options, $context)
    {
        if (!is_array($stepActionParams)) {
            throw new InvalidConfigurationException(
                "Step '".self::STEP_VALIDATE_OBJECT_OUTPUT."' in AbstractConfigurableProducer expected an array as configuration"
            );
        }

        $stepParamsResolver = new OptionsResolver();

        $stepParamsResolver->setRequired([
            self::OUTPUT_OBJECT,
            self::OUTPUT_GROUP,
            self::OUTPUT_DISPLAY_ERROR,
        ]);

        $params = $stepParamsResolver->resolve($stepActionParams);

        $object = $this->confHelper->resolve($params[self::OUTPUT_OBJECT], $context);
        $group = $this->confHelper->resolve($params[self::OUTPUT_GROUP], $context);
        $showError = $this->confHelper->resolve($params[self::OUTPUT_DISPLAY_ERROR], $context);

        $version = $context['exchange']->getHeaders()['apiVersion'];

        $this->getHydrator()->hydrate($object, $group, $version);
        $validator = $this->getValidator();
        $errors = $validator->validate($object);
        if (count($errors) > 0) {
            $message = '';
            foreach ($errors as $error) {
                $message .= $error->getPropertyPath().' - '.$error->getMessage().' | ';
            }
            $exception = new ExternalSystemException($message);
            $exception->setExternalSystemName($this->getName());
            $exception->setShowExternalSystemErrorMessage($showError);
            throw $exception;
        }
    }
192354
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        if (!isset($options['folders'])) {
            return;
        }
        $folders = $options['folders'];
        if (!is_array($folders)) {
            $folders = [$folders];
        }
        $replacePaths = [
            '{deploymentPath}' => escapeshellarg($application->getDeploymentPath()),
            '{sharedPath}' => escapeshellarg($application->getSharedPath()),
            '{releasePath}' => escapeshellarg($deployment->getApplicationReleasePath($application)),
            '{currentPath}' => escapeshellarg($application->getReleasesPath() . '/current'),
            '{previousPath}' => escapeshellarg($application->getReleasesPath() . '/previous')
        ];

        $commands = [];

        $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->onLocalhost();

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