public function run(Context $context) { // Check for required environment param if (($env = $context->getArgument(['e', 'environment'])) === null) { throw new \Exception("No environment specified"); } // Get the environment config if (($environment = $context->config->getEnvironment($env)) == false) { throw new \Exception("No environment config found for \"{$env}\"."); } if ($environment->preDeploy) { $connection = new LocalConnection(); foreach ($environment->preDeploy as $task) { Task::run($task, $context, $environment, $connection); } } // loop through servers and implement strategy on each foreach ($environment->servers as $server) { if (empty($server->strategy)) { throw new \Exception("No strategy defined! Please define a global, environmental, or per-server strategy. See the manual for defining strategies."); } $connection = new RemoteConnection($server, $environment->authentication); foreach ($server->strategy as $task) { Task::run($task, $context, $environment, $connection); } $connection->close(); } if ($environment->postDeploy) { $connection = new LocalConnection(); foreach ($environment->postDeploy as $task) { Task::run($task, $context, $environment, $connection); } } }
public function run(Context $context) { // Get environment argument if (($env = $context->getArgument(['e', 'environment'])) === null) { throw new \Exception("No environment specified"); } // Get task argument if (($task = $context->nextNamedArgument()) == null) { throw new \Exception("No task specified. Specify a task with either -t or --task argument."); } // Get the environment config if (($environment = $context->config->getEnvironment($env)) == false) { throw new \Exception("No environment config found for \"{$env}\"."); } // loop through servers and run task foreach ($environment->servers as $server) { $connection = new RemoteConnection($server, $environment->authentication); Task::run($task, $context, $environment, $connection); $connection->close(); } }