projectStore = $projectStore; $this->buildService = $buildService; } /** * {@inheritDoc} */ protected function configure() { $this ->setName('phpci:create-build') ->setDescription(Lang::get('create_build_project')) ->addArgument('projectId', InputArgument::REQUIRED, Lang::get('project_id_argument')) ->addOption('commit', null, InputOption::VALUE_OPTIONAL, Lang::get('commit_id_option')) ->addOption('branch', null, InputOption::VALUE_OPTIONAL, Lang::get('branch_name_option')); } /** * {@inheritDoc} */ public function execute(InputInterface $input, OutputInterface $output) { $projectId = $input->getArgument('projectId'); $commitId = $input->getOption('commit'); $branch = $input->getOption('branch'); $project = $this->projectStore->getById($projectId); if (empty($project)) { throw new \InvalidArgumentException('Project does not exist: ' . $projectId); } try { $this->buildService->createBuild($project, $commitId, $branch); $output->writeln(Lang::get('build_created')); } catch (\Exception $e) { $output->writeln(sprintf('%s', Lang::get('failed'))); $output->writeln(sprintf('%s', $e->getMessage())); } } }