Beispiel #1
0
 public function update(&$rev)
 {
     // We can't use "git --git-dir={$this->getLocal()} pull", it's wrong
     $drive = '';
     if (Framework_HostOs::isWindows()) {
         $drive = substr($this->getLocal(), 0, strpos($this->getLocal(), ':') + 1) . ' && ';
     }
     $command = (empty($this->_envVars) ? '' : $this->getEnvVars() . ' && ') . "{$drive} cd {$this->getLocal()} && {$GLOBALS['settings'][SystemSettings::EXECUTABLE_GIT]} pull";
     $proc = new Framework_Process();
     $proc->setExecutable($command, false);
     // false for no escapeshellcmd() (because of the ';')
     $proc->run();
     if (($return = $proc->getReturnValue()) != 0) {
         SystemEvent::raise(SystemEvent::ERROR, "Could not update local working copy. [COMMAND=\"{$command}\"] [RET={$return}] [STDERR=\"{$proc->getStderr()}\"] [STDOUT=\"{$proc->getStdout()}\"]", __METHOD__);
         return false;
     }
     $rev = $this->_getLocalRevision();
     SystemEvent::raise(SystemEvent::DEBUG, "Updated local. [REV={$rev}] [COMMAND=\"{$command}\"] [RET={$return}] [STDERR=\"{$proc->getStderr()}\"] [STDOUT=\"{$proc->getStdout()}\"]", __METHOD__);
     return true;
 }
Beispiel #2
0
 public function generateReleasePackage()
 {
     $ret = false;
     if ($this->getStatus() != self::STATUS_FAIL) {
         $project = $this->getPtrProject();
         // Easier handling
         $filename = "{$project->getReleasesDir()}{$project->getReleaseLabel()}-{$this->getId()}";
         //
         // Rename the sources dir to the new dir that will be archived
         //
         $releaseDirName = "{$project->getReleaseLabel()}-{$this->getId()}";
         $releaseDirPath = "{$project->getTempDir()}{$releaseDirName}";
         if (!@rename($project->getSourcesDir(), $releaseDirPath)) {
             SystemEvent::raise(SystemEvent::ERROR, "Problems creating release dir. [BUILD={$this->getId()}] [PID={$project->getId()}]", __METHOD__);
             return false;
         }
         //
         // TODO: For now only tar is available. As soon as more are implemented,
         // it is required that Project keeps it's preferred archiver, so
         // that it can be fetched here and fed into getCmdForPackageGeneration()
         //
         $params = array('tmpDir' => $project->getTempDir(), 'archiverExecutable' => SystemSettings::EXECUTABLE_TAR, 'releaseLabel' => $filename, 'sourcesDir' => $releaseDirName);
         $command = $GLOBALS['settings']->getCmdForPackageGeneration($params);
         $command = str_replace('\\', '/', $command);
         $command = str_replace('//', '/', $command);
         if (preg_match("/({$project->getReleaseLabel()}-{$this->getId()}[.\\w]+) /", $command, $matches)) {
             $filename = $matches[1];
             // Get the filename extension
         }
         $proc = new Framework_Process();
         $proc->setExecutable($command, false);
         $proc->run();
         if ($proc->getReturnValue() == 0) {
             $this->setReleaseFile($filename);
             $this->setStatus(self::STATUS_OK_WITH_PACKAGE);
             $ret = true;
             SystemEvent::raise(SystemEvent::DEBUG, "Generated release package for build. [BUILD={$this->getId()}] [PID={$project->getId()}] [COMMAND={$command}]", __METHOD__);
         } else {
             SystemEvent::raise(SystemEvent::ERROR, "Problems generating release package for build. [BUILD={$this->getId()}] [PID={$project->getId()}] [COMMAND={$command}]", __METHOD__);
         }
         // Remove the release dir
         Framework_Filesystem::removeDir($releaseDirPath);
     }
     return $ret;
 }
Beispiel #3
0
 public function isModified()
 {
     $credentials = $this->_getCredentialsArgs();
     //
     // svn info the local sources
     //
     /*
     # svn info http://cintient.googlecode.com/svn/trunk/ ./
     svn: warning: cannot set LC_CTYPE locale
     svn: warning: environment variable LC_CTYPE is US-ASCII
     svn: warning: please check that your locale name is correct
     Path: trunk
     URL: http://cintient.googlecode.com/svn/trunk
     Repository Root: http://cintient.googlecode.com/svn
     Repository UUID: b5843765-8500-0169-a8a4-cd43f2d668ef
     Revision: 359
     Node Kind: directory
     Last Changed Author: pedro.matamouros
     Last Changed Rev: 359
     Last Changed Date: 2011-09-18 11:32:48 +0100 (Sun, 18 Sep 2011)
     
     Path: .
     URL: http://cintient.googlecode.com/svn/trunk
     Repository Root: http://cintient.googlecode.com/svn
     Repository UUID: b5843765-8500-0169-a8a4-cd43f2d668ef
     Revision: 358
     Node Kind: directory
     Schedule: normal
     Last Changed Author: pedro.matamouros
     Last Changed Rev: 358
     Last Changed Date: 2011-09-18 11:30:30 +0100 (Sun, 18 Sep 2011)
     */
     $command = (empty($this->_envVars) ? '' : $this->getEnvVars() . ' && ') . "{$GLOBALS['settings'][SystemSettings::EXECUTABLE_SVN]} info {$credentials}--non-interactive {$this->getRemote()} {$this->getLocal()}";
     $proc = new Framework_Process();
     $proc->setExecutable($command, false);
     $proc->run();
     if (($return = $proc->getReturnValue()) != 0) {
         SystemEvent::raise(SystemEvent::ERROR, "Could not check info on repository. [COMMAND=\"{$command}\"] [RET={$return}] [STDERR=\"{$proc->getStderr()}\"] [STDOUT=\"{$proc->getStdout()}\"]", __METHOD__);
         return false;
     }
     $output = $proc->getStdout();
     if (!preg_match_all('/^Revision: (\\d+)$/m', $output, $matches) || !isset($matches[1][0]) || !isset($matches[1][1])) {
         SystemEvent::raise(SystemEvent::ERROR, "Could not check for modifications. [OUTPUT=\"{$output}\"]", __METHOD__);
         return false;
     }
     #if DEBUG
     SystemEvent::raise(SystemEvent::DEBUG, "Repository " . ($matches[1][0] != $matches[1][1] ? '' : 'not ') . "changed.", __METHOD__);
     #endif
     return $matches[1][0] != $matches[1][1];
 }