Exemplo n.º 1
0
 /**
  * Determine if there are any builds pending, and launch any of those builds up to the max number of builds
  * allowed to run at once.
  */
 public function run()
 {
     $building = $this->buildRepository->getBy(['status' => 'building']);
     if (count($building) < $this->maxBuildsInProgress) {
         $pending = $this->buildRepository->getBy(['status' => 'pending'], ['created' => 'ASC'], $this->maxBuildsInProgress - count($building));
         foreach ($pending as $build) {
             // Find a cleaner, more graceful way to do this:
             exec('./bin/martha ' . $build->getId() . ' > /dev/null &');
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @param Build $build
  * @param bool $success
  */
 protected function completeBuild(Build $build, $success)
 {
     // Loop each artifact generated by the build:
     foreach ($build->getArtifacts() as $artifact) {
         // Get the handler for the artifact:
         $artifactHandler = $this->system->getPluginManager()->getArtifactHandler($artifact->getHelper());
         // If we're an instance of BuildStatisticInterface, generate the relevant statistics:
         if ($artifactHandler && $artifactHandler instanceof BuildStatisticInterface) {
             $artifactHandler->parseArtifact($build, file_get_contents($artifact->getFile()));
             $artifactHandler->generateBuildStatistics($build);
         }
     }
     $build->setStatus($success ? Build::STATUS_SUCCESS : Build::STATUS_FAILURE);
     $this->buildRepository->flush();
     $this->system->getEventManager()->trigger('build.complete', $build);
     $this->system->getEventManager()->trigger('build.' . ($success ? 'success' : 'failure'), $build);
 }