예제 #1
0
 protected function _exec($command)
 {
     $task = new ExecTask();
     $task->setProject($this->project);
     $task->setCommand($command);
     $task->setCheckreturn(true);
     $task->setLogoutput(true);
     $task->setLevel('info');
     $this->log($command, Project::MSG_INFO);
     return $task->main();
 }
예제 #2
0
 public function main()
 {
     if (empty($this->_target)) {
         $message = 'Param "target" not found.';
         throw new BuildException($message);
     }
     $this->_checkHost($this->_host);
     $msg = sprintf("Host: %s, IPs found: %s", $host, implode(' ', $this->_ips));
     $this->log($msg);
     $msg = sprintf('Target: %s', $this->_target);
     $this->log($msg);
     $commandAr = array();
     $buildDirRoot = $this->getProject()->getProperty('build.dir.root');
     $commandAr[] = $buildDirRoot . '/bin/phing';
     $projectBasedir = $this->getProject()->getProperty('project.basedir');
     $commandAr[] = sprintf('-f %s/build.xml', $projectBasedir);
     $commandAr[] = $this->_target;
     $buildType = $this->getProject()->getProperty('build.type');
     $commandAr[] = sprintf('-Dbt=%s', $buildType);
     $buildUser = $this->getProject()->getProperty('build.user');
     if ($buildUser) {
         $commandAr[] = sprintf('-Dbu=%s', $buildUser);
     }
     $buildBranch = $this->getProject()->getProperty('build.branch');
     if ($buildBranch) {
         $commandAr[] = sprintf('-Dbb=%s', $buildBranch);
     }
     foreach ($this->_ips as $ip) {
         $command = sprintf('ssh %s %s', $ip, implode(' ', $commandAr));
         $msg = 'Run command ' . $command;
         $this->log($msg);
         $returnProp = 'remote.return';
         $outputProp = 'remote.output';
         $obj = new ExecTask();
         $obj->setProject($this->project);
         $obj->setCommand($command);
         $obj->setLogoutput(true);
         $obj->setReturnProperty($returnProp);
         $obj->setOutputProperty($outputProp);
         $obj->setCheckreturn($this->_checkreturn);
         $obj->setPassthru(true);
         $obj->setLevel('info');
         $obj->main();
     }
 }