Skip to content

Instantly share code, notes, and snippets.

@yudanta
Last active January 3, 2016 22:09
Show Gist options
  • Save yudanta/8526201 to your computer and use it in GitHub Desktop.
Save yudanta/8526201 to your computer and use it in GitHub Desktop.
simple php script to handle gitlab webhook post data
<?php
try {
if ($HTTP_RAW_POST_DATA)
{
if ($git_hook_data = json_decode($HTTP_RAW_POST_DATA))
{
$fn = fopen('hook.log.txt', 'w') or die('cant open file');
fwrite($fn, "hook data received at: ".date('Y-m-d H:i:s')."\n");
fwrite($fn, print_r($git_hook_data, true));
fclose($fn);
}
}
else
{
$fn = fopen('hook.log.txt', 'w');
fwrite($fn, 'no post received');
fclose($fn);
}
} catch (Exception $e) {
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment