Open gjonespf opened 6 years ago
Out of interest, using Cake to generate a "version file" with this info is as easy the below. But without fiddling/dipping into env vars, the parameters listed above aren't usable in build scripts. This is somewhat similar to how you're creating the "version.cake" file on each build as part of building Cake.Recipe itself.
#addin "nuget:https://www.nuget.org/api/v2?package=Newtonsoft.Json"
using Newtonsoft.Json;
Task("Generate-Version-File")
.Does(() => {
var versionData = JsonConvert.SerializeObject(BuildParameters.Version, Formatting.Indented);
System.IO.File.WriteAllText(
"./BuildVersion.json",
versionData
);
});
Keen on having access to the following items as part of build scripts from e.g. GitVersion:
Branch name
Commit Hash (SHA)
Commit Date
Usually have all these items in a simple JSON file bundled with each release, regardless of which versioning scheme I'm using for a particular project, to ensure I can trace the provenance for a particular package/release/deployment etc.
Could be achieved by adding to e.g. https://github.com/cake-contrib/Cake.Recipe/blob/08ca8d06ae0b7d25a94780f1424e966fd9d2348e/Cake.Recipe/Content/gitversion.cake#L10
But may be muddying purpose of that class/method.