1

私のクラスの下:

class JenkinsDiffEventListener extends PhutilEventListener {

  public function register() {
    $this->listen(ArcanistEventType::TYPE_DIFF_WASCREATED);
  }

  public function handleEvent(PhutilEvent $event) {
    $diff_id = $event->getValue('diffID');

    /* Need to send a get request to jenkins to trigger the job. We pass the
     * diff id to jenkins via its api.
     */
    $workflow = $event->getValue('workflow');
    $jenkins_uri = $workflow->getConfigFromAnySource('jenkins.uri');
    $jenkins_jobs = $workflow->getConfigFromAnySource('jenkins.jobs');

    if (!$jenkins_uri || !$jenkins_jobs) {
      return;
    }

    foreach ($jenkins_jobs as $job) {
        $url = $jenkins_uri."/job/".$job."/buildWithParameters?DIFF_ID=".$diff_id;
        file_get_contents($url);
    }
  }
}

このクラスから現在の git ブランチの名前を取得する方法を知っていますか? 以下のようなことをしたいと思います。

$branch = $workflow->getSomething()->getBranch();
$url = $jenkins_uri."/job/".$job."/buildWithParameters?DIFF_ID=".$diff_id."&BRANCH=".$branch;

ありがとう

4

1 に答える 1

1

私は答えを見つけました:

$branch = $workflow->getRepositoryAPI()->getBranchName();

ありがとう

于 2013-12-04T08:31:04.970 に答える