如何知道奥术师事件中的分支名称

时间:2013-12-03 14:58:45

标签: git events phabricator

在我的课程下面:

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;

由于

1 个答案:

答案 0 :(得分:1)

我找到了答案:

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

由于

相关问题