We need:
- Apache
- PHP
The main page of site 🙂
[code language=”php”]
<html>
<head>
<LINK REL="stylesheet" href="" type="text/css">
<title>builder</title>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"/>
</head>
<body>
<?php
$res = shell_exec("tasklist");
if (preg_match(‘/^git\.exe/im’, $res) || preg_match(‘/^dcc32\.exe/im’, $res))
{echo ‘<p>Oops, building… Come back later.</p>’;}
else
{
echo "<p>Hello dear programmer.<br>I hope you’ve finished developing of branch and want to test it<br>Please enter the name of the branch and click button ‘Build branch'</p>";
echo ‘<form name="buildbranchXE" method="POST" action="/buildbranch.php"><input type="text" name="branchname" value="" /><input type="submit" value="Build branch" /></form>’;
}
?>
</body>
</html>
[/code]
File buildbranch.php
[code language=”php”]
<?php
$res = shell_exec("tasklist");
if (preg_match(‘/^git\.exe/im’, $res) || preg_match(‘/^dcc32\.exe/im’, $res))
{
echo ‘<p>Oops, building… Come back later.</p>’;
}
else
{
$brname=$_POST["branchname"];
if (!isset($brname) || empty($brname)) {header(‘Location: /error.html’);exit();}
$r = exec("start /B cmd /c c:\cron\git-check-branch.bat ".$brname);
if (strcasecmp(trim($r), trim("origin/".$brname)) == 0)
{
pclose(popen("start /B cmd.exe /c c:\cron\git-branch.bat ".$brname, "r"));
echo ‘<p>Building…</p>’;
}
else
{echo ‘The branch does not exist’;}
}
?>
[/code]
File git-check-branch.bat
[code language=”plain”]
cd c:\repo
git branch –list -r | grep origin/%1
[/code]
File git-branch.bat execute building of application