actually i'm using Jenkins for create projects.
The API say that we can update a config.xml file with POST a new.
I know it works with cgwin code:
#Update the configuration via posting a local configuration file
curl -X POST http://ift.tt/1x0Cweo --data-binary "@mymodifiedlocalconfig.xml"
I wanted to use PHP to update my config.xml file project (use Jenkins API), in the API Doc it says i must to POST a new config.xml file, there is my php code :
$newconfig = '/var/www/mynewconfig/config.xml';
if(!$xml_builder = simplexml_load_file($file))
exit('Failed to open '.$file);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ift.tt/1sY3ipq");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
$ch_result = curl_exec($ch);
curl_close($ch);
// Print CURL result.
echo $ch_result;
this code doesnt works.
Someone have a part of a code that works ? Or adpat the 1st code to php curl ? I'm not a Pro-PHP
No comments:
Post a Comment