/**
  * @param Build $build
  * @return bool|AbstractProvider
  */
 public static function createForBuild(Build $build)
 {
     switch (strtolower($build->getProject()->getScm())) {
         case 'git':
             $git = new Git();
             if ($build->getForkUri()) {
                 $git->setRepository($build->getForkUri());
             } else {
                 $git->setRepository($build->getProject()->getUri());
             }
             return $git;
     }
     return false;
 }
Beispiel #2
0
 /**
  * Setup the directory structure needed for the build.
  *
  * @param Build $build
  * @return $this
  */
 protected function setupEnvironment(Build $build)
 {
     $environment = new Environment();
     $environment->setPrivateKey($build->getProject()->getCreatedBy()->getPrivateKey());
     $environment->setUp();
     $this->system->getEventManager()->trigger('build.pre.environment', $build);
     $this->workingDir = $this->buildDirectory . '/' . $build->getProject()->getName() . '/' . $build->getId();
     $this->outputDir = $this->dataDirectory . '/' . $build->getProject()->getName() . '/' . $build->getId();
     if (!file_exists($this->workingDir)) {
         mkdir($this->workingDir, 0775, true);
     }
     if (!file_exists($this->outputDir)) {
         mkdir($this->outputDir, 0775, true);
     }
     $this->outputFile = $this->outputDir . '/console.html';
     touch($this->outputFile);
     $this->log('Working Directory: ' . $this->workingDir);
     $this->scm = ProviderFactory::createForBuild($build);
     $this->scm->setEnvironment($environment);
     $this->scm->setLogFile($this->outputFile);
     $this->system->getEventManager()->trigger('build.post.environment', $build);
     return $this;
 }
 /**
  * Strip off the irrelevant part of the file name (build path) and return the shortened file name.
  *
  * @param string $file
  * @return string
  */
 protected function stripBuildPath($file)
 {
     $base = $this->build->getProject()->getName() . '/' . $this->build->getId();
     return substr($file, strpos($file, $base) + strlen($base) + 1);
 }