开发者

Hudson: Posting config.xml with php curl?

开发者 https://www.devze.com 2023-01-23 19:49 出处:网络
I keep getting 400. I have no security enabled on my hudson server. <?php $url = \"http://myhudsonserverIP/createItem?name=开发者_如何学CNEWJOB\";

I keep getting 400. I have no security enabled on my hudson server.

<?php

$url = "http://myhudsonserverIP/createItem?name=开发者_如何学CNEWJOB";

$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);

?>


You have to add a query parameter for which job you would like to create the configuration.

URL/.../createItem?name=ProjectName

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号