Example #1
0
 /**
  * @return Job[]
  */
 public function getJobs()
 {
     $jobs = array();
     foreach ($this->view->jobs as $job) {
         $jobs[] = $this->jenkins->getJob($job->name);
     }
     return $jobs;
 }
 /**
  * @param $requestType      $this::GET or $this::POST
  * @param $url              String
  * @param array $params Array
  * @param bool $failOnError true or false
  * @param bool $showHeader true or false
  * @param array $moreOpts
  * @return string
  */
 protected function sendRequest($requestType, $url, array $params = null, $failOnError = true, $showHeader = true, array $moreOpts = array())
 {
     $curlOpt = array();
     if ($requestType == $this::GET) {
     } elseif ($requestType == $this::POST) {
         $curlOpt[CURLOPT_POST] = true;
         if ($params != null && count($params) > 0) {
             $paramString = "";
             $i = 0;
             foreach ($params as $key => $value) {
                 if ($i == 0) {
                     $paramString .= $key . "=" . $value;
                 } else {
                     $paramString .= "&" . $key . "=" . $value;
                 }
                 $i++;
             }
             $curlOpt[CURLOPT_POSTFIELDS] = $paramString;
         }
     }
     if ($failOnError) {
         $curlOpt[CURLOPT_FAILONERROR] = true;
     }
     if ($showHeader) {
         $curlOpt[CURLOPT_HEADER] = true;
     }
     if (count($moreOpts) > 0) {
         foreach ($moreOpts as $opt => $val) {
             $curlOpt[$opt] = $val;
         }
     }
     $curlOpt[CURLOPT_RETURNTRANSFER] = 1;
     $curlOpt[CURLOPT_SSL_VERIFYPEER] = $this->sslVerify ? 64 : 0;
     $response = $this->jenkinsClient->execute($url, $curlOpt);
     return $response;
 }
Example #3
0
 /**
  * @return string
  *
  * @throws \RuntimeException
  */
 public function retrieveXmlConfigAsString()
 {
     return $this->jenkins->retrieveXmlConfigAsString($this->getName());
 }