1.20.x run_tests.php | zenci_put_request($data) |
Submit a POST request to Zen.ci updating its current status.
Parameters
array $data: An array of data to push to Zen.ci. Should include the following:
- state: One of "error", "success", or "pending".
- message: A string summary of the state.
- summary: Optional. A longer description of the state.
File
- misc/
zen-ci/ run_tests.php, line 73 - This script file is executed on the Zen.ci platform for running tests.
Code
function zenci_put_request($data) {
$token = getenv('GITLC_API_TOKEN');
$status_url = getenv('GITLC_STATUS_URL');
$data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $status_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); // Note the PUT here.
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Token: ' . $token,
'Content-Length: ' . strlen($data)
));
curl_exec($ch);
curl_close($ch);
}