2lach
02/03/2024, 7:51 AMxml
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="git rev-parse HEAD > $(ProjectDir)properties\commit.txt" />
</Target>
I found a nifty solution (imo). Instead of attempting to commit a file with the latest Git SHA, I now generate it in a file called commit.txt
during the build process. This way, I can easily parse and display the value. I've also added the file to .gitignore
locally to prevent Git conflicts.
That the how
This worked smoothly on my local setup, but on Umbraco Cloud, it posed challenges.
As a Mac/Linux user, I'm not well-versed in Windows servers.
While exploring Kudu tools, I discovered that significant changes occur between pushing my code to Umbraco Cloud and its deployment, including alterations to the entire file structure. Despite performing a thorough PowerShell search on the server's hard drive, my "commit.txt" file was nowhere to be found.
Thats the WTF
So my question is
When creating a file on the fly containing the latest Git SHA value, where can I store it so it's reachable (on the win server) and there is a const/absolute path I can use to parse the value?
> It doesn't have to work locally but should always work from my Umbraco cloud server
That's the question
Thanks for reading any helpful advice is most welcome 👍
PS
I know this can be solved with CI/CD pipelines and injecting the git sha as an env var, but honestly i don't want to rebuild the entire CD/CI process just to display a git sha.Ambert
02/03/2024, 12:09 PMAmbert
02/03/2024, 12:10 PM2lach
02/03/2024, 5:28 PM2lach
02/03/2024, 7:38 PM2lach
02/03/2024, 7:41 PMAmbert
02/03/2024, 7:44 PMAmbert
02/03/2024, 7:44 PMA hub and casual space for you to interact with fellow community members and learn more about Umbraco!
Powered by