【问题标题】:Hudson: Posting config.xml with php curl?Hudson:使用 php curl 发布 config.xml?
【发布时间】:2011-05-04 07:03:03
【问题描述】:

我不断收到 400。我没有在我的 hudson 服务器上启用安全性。

<?php

$url = "http://myhudsonserverIP/createItem?name=NEWJOB";

$post_string = file_get_contents("config.xml");


$header  = "POST HTTP/1.0 \r\n";
$header .= "Content-type: text/xml \r\n";
$header .= "Content-length: ".strlen($post_string)." \r\n";
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Connection: close \r\n\r\n";
$header .= $post_string;

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);

$data = curl_exec($ch);

//DUMP OUT HEADER
echo var_dump($data);

?>

【问题讨论】:

    标签: php hudson


    【解决方案1】:

    您必须为要创建configuration 的作业添加查询参数。

    URL/.../createItem?name=ProjectName

    【讨论】:

      猜你喜欢
      • 2011-12-19
      • 2020-12-09
      • 1970-01-01
      • 1970-01-01
      • 2022-06-17
      • 1970-01-01
      • 2011-03-15
      • 2011-05-18
      • 2016-08-10
      相关资源
      最近更新 更多