* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Cintient. If not, see <http://www.gnu.org/licenses/>. * */ // TODO: centralize the initalization stuff that is common to web, ajax // and builder handlers. (this builder could be called by a crontab) require_once dirname(__FILE__) . '/../config/cintient.conf.php'; SystemEvent::setSeverityLevel(CINTIENT_LOG_SEVERITY); $GLOBALS['settings'] = SystemSettings::load(); // Pull up system settings // Temporarily disable the background build handler in Windows, while // binaries aren't being dealt with in the installer. if (Framework_HostOs::isWindows()) { SystemEvent::raise(SystemEvent::INFO, "Background builds are temporarily disabled in Windows.", 'buildHandler'); return false; } $buildProcess = new Framework_Process($GLOBALS['settings'][SystemSettings::EXECUTABLE_PHP]); $buildProcess->addArg(CINTIENT_INSTALL_DIR . 'src/workers/runBuildWorker.php'); if (!$buildProcess->isRunning()) { if (!$buildProcess->run(true)) { SystemEvent::raise(SystemEvent::ERROR, "Problems starting up build worker.", 'buildHandler'); } else { SystemEvent::raise(SystemEvent::INFO, "Build worker left running in the background.", 'buildHandler'); } } else { SystemEvent::raise(SystemEvent::DEBUG, "Build process already running.", 'buildHandler'); } #endif
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; }
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; }
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]; }