Example #1
0
 public function run()
 {
     list($options, $flags, $extra) = $this->options_tuple;
     $this->repo_manager->setRemoteBranch($options->branch);
     // Resolve the given remote branch value to a real ref.
     $remote_branch = $this->repo_manager->getRemoteBranch();
     if ($options->whitelist) {
         $whitelist = $options->whitelist;
         if (is_string($whitelist)) {
             $whitelist = array($whitelist);
         }
     } else {
         $whitelist = $this->whitelisted_files;
     }
     $this->repo_manager->runPrechecks($this->prechecks);
     $patch = $options->patch;
     if ($options->patch_stdin) {
         $patch = $this->readPatchFromStdin($options->wcpath);
     }
     if (is_null($patch)) {
         $patch = $this->repo_manager->generateDiff($options->staged, $whitelist);
     }
     if ($options->diff_only) {
         print 'Not sending job to Jenkins (-n) diff is here:' . $patch . PHP_EOL;
         exit(0);
     }
     $this->jenkins_runner->setPatch(realpath($patch));
     if ($this->ssh_key_path) {
         $this->jenkins_runner->setSshKey($this->ssh_key_path);
     }
     $this->jenkins_runner->setParam('branch', $remote_branch);
     $this->jenkins_runner->setParam('guid', $this->override_user . time());
     $extra_params = TryLib_Util_OptionsUtil::parseExtraParameters($options->extra_param);
     foreach ($extra_params as $param) {
         $this->jenkins_runner->setParam($param[0], $param[1]);
     }
     $this->jenkins_runner->addCallback($options->callback);
     $this->jenkins_runner->startJenkinsJob($options->show_results, $options->show_progress);
     return $this->jenkins_runner->try_status === 'FAILURE' ? 1 : 0;
 }
Example #2
0
 /**
  * @dataProvider provideExtraParameters
  */
 function testParseExtraParameters($extra_param_option, $expected_params)
 {
     $actual_params = TryLib_Util_OptionsUtil::parseExtraParameters($extra_param_option);
     $this->assertEquals($expected_params, $actual_params);
 }