public function onBuildFinished(BuildFinishedEvent $event) { if (!$this->enabled) { return; } $build = $event->getBuild(); if (!$build->isRunning()) { return; } $project = $build->getProject(); $provider = $this->providerFactory->getProvider($project); $provider->sendPullRequestComment($project, $build); }
/** * @param LifecycleEventArgs */ public function prePersist(LifecycleEventArgs $args) { $build = $args->getEntity(); if (!$this->supports($build)) { return; } $em = $this->doctrine->getManager(); $pr = $this->doctrine->getRepository('Model:PullRequest')->findOneBy(['project' => $build->getProject()->getId(), 'ref' => $build->getRef()]); if (!$pr) { $this->logger->info('creating non-existing pr', ['project' => $build->getProject()->getId(), 'ref' => $build->getRef()]); $project = $build->getProject(); if (null === $project) { $this->logger->info('could not find a project for build', ['build_id' => $build->getId()]); } $provider = $this->providerFactory->getProvider($project); $pr = $provider->createPullRequestFromPayload($project, $build->getRawPayload()); $em->persist($pr); } $build->setPullRequest($pr); }
public function onBuildFinished(BuildFinishedEvent $event) { if (!$this->enabled) { return; } $build = $event->getBuild(); if (!$build->isRunning()) { $this->logger->info('skipping commit status for non-running build'); return; } if (strlen($build->getHash()) === 0) { $this->logger->info('skipping commit status because of empty commit hash'); return; } $project = $build->getProject(); if (null === $project) { $this->logger->info('could not find a project for build', ['build_id' => $build->getId()]); return; } $provider = $this->providerFactory->getProvider($project); $provider->setCommitStatus($project, $build, 'success'); }