예제 #1
0
 /**
  * Handle any post-clone tasks, like applying a pull request patch on top of the branch.
  * @param Builder $builder
  * @param $cloneTo
  * @return bool
  */
 protected function postCloneSetup(Builder $builder, $cloneTo)
 {
     $buildType = $this->getExtra('build_type');
     $success = true;
     try {
         if (!empty($buildType) && $buildType == 'pull_request') {
             $remoteUrl = $this->getExtra('remote_url');
             $remoteBranch = $this->getExtra('remote_branch');
             $cmd = 'cd "%s" && git checkout -b phpci/' . $this->getId() . ' %s && git pull -q --no-edit %s %s';
             $success = $builder->executeCommand($cmd, $cloneTo, $this->getBranch(), $remoteUrl, $remoteBranch);
         }
     } catch (\Exception $ex) {
         $success = false;
     }
     if ($success) {
         $success = parent::postCloneSetup($builder, $cloneTo);
     }
     return $success;
 }
예제 #2
0
 /**
  * @inheritDoc
  */
 public function reportError(Builder $builder, $plugin, $message, $severity = BuildError::SEVERITY_NORMAL, $file = null, $lineStart = null, $lineEnd = null)
 {
     $diffLineNumber = $this->getDiffLineNumber($builder, $file, $lineStart);
     if (!is_null($diffLineNumber)) {
         $helper = new Github();
         $repo = $this->getProject()->getReference();
         $prNumber = $this->getExtra('pull_request_number');
         $commit = $this->getCommitId();
         if (!empty($prNumber)) {
             $helper->createPullRequestComment($repo, $prNumber, $commit, $file, $diffLineNumber, $message);
         } else {
             $helper->createCommitComment($repo, $commit, $file, $diffLineNumber, $message);
         }
     }
     return parent::reportError($builder, $plugin, $message, $severity, $file, $lineStart, $lineEnd);
 }