Пример #1
0
 /**
  * @param string $url
  * @param string $body
  *
  * @return string
  */
 private function callJenkins($url, $body = '')
 {
     $post_url = Config::get(SetupConstants::JENKINS_BASE_URL) . '/' . $url;
     //createItem?name=" . $v['name'];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $post_url);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: text/xml']);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     Log::logRaw('CURL call: ' . $post_url . "body:\n[" . $body . "]\n\n", self::LOGFILE);
     $head = curl_exec($ch);
     Log::logRaw("CURL response:\n[" . $head . "]\n\n", self::LOGFILE);
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     return $httpCode;
 }