I am looking for a way to automatically fetch those information on a cloudControl container. So I wrote a little Symfony2 service that returns some git information, e.g. the commit hash
public function getCommitHash() {
exec('git rev-parse --short HEAD', $output);
$hash = implode(', ', $output);
return $hash;
}
If I run this on my local machine, it returns the proper shortened commit hash. But if I push this to my cloudControl machine, the return is null
. I manually connected to the machine and ran this command on the command line (in the www
folder, that is where the repository is pushed into). That throws the following error:
fatal: Not a git repository (or any parent up to mount parent )
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
I am really confused, as I thought I simply push my whole repository (including the .git
folder) onto the remote machine. Why do I get this error and how can I fetch the git information instead?
If you want to use the git version within your running container, you can use the environment variable DEP_VERSION
. E.g.:
<?php
echo 'This container is running git commit ' .$_ENV["DEP_VERSION"] . '.';
?>