Beispiel #1
0
 /**
  * Enable a GitLab webhook for the given Package.
  * 
  * @param Package $package
  *
  * @return bool
  */
 public function enableHook(Package $package)
 {
     $config = $this->getConfig($package);
     if ($config->isEnabled()) {
         return true;
     }
     $client = $this->getClient($package->getRemote());
     $project = Project::fromArray($client, (array) $client->api('projects')->show($package->getExternalId()));
     $hook = $project->addHook($this->urlGenerator->generate('webhook_receive', array('id' => $package->getId()), true), array('push_events' => true, 'tag_push_events' => true));
     $package->setHookExternalId($hook->id);
     $config->setEnabled(true);
     return true;
 }
Beispiel #2
0
 /**
  * Enable a GitHub webhook for the given Package
  * 
  * @param Package $package
  *
  * @return bool
  */
 public function enableHook(Package $package)
 {
     $config = $this->getConfig($package);
     if ($config->isEnabled()) {
         return true;
     }
     $client = $this->getClient($package->getRemote());
     $url = 'repos/' . $package->getFqn() . '/hooks';
     $response = $client->getHttpClient()->post($url, json_encode(array('name' => 'web', 'config' => array('url' => $this->urlGenerator->generate('webhook_receive', array('id' => $package->getId()), true), 'content_type' => 'json'), 'events' => array('push', 'create'))));
     $hook = ResponseMediator::getContent($response);
     $package->setHookExternalId($hook['id']);
     $config->setEnabled(true);
     return true;
 }