GH-86 - Dynamically set the GitVersion output properties
This commit is contained in:
@@ -109,77 +109,20 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
||||
}
|
||||
|
||||
public writeGitVersionToAgent(gitversion: GitVersionOutput): void {
|
||||
this.buildAgent.setOutput('major', gitversion.Major.toString())
|
||||
this.buildAgent.setOutput('minor', gitversion.Minor.toString())
|
||||
this.buildAgent.setOutput('patch', gitversion.Patch.toString())
|
||||
this.buildAgent.setOutput('preReleaseTag', gitversion.PreReleaseTag)
|
||||
this.buildAgent.setOutput(
|
||||
'preReleaseTagWithDash',
|
||||
gitversion.PreReleaseTagWithDash
|
||||
)
|
||||
this.buildAgent.setOutput('preReleaseLabel', gitversion.PreReleaseLabel)
|
||||
this.buildAgent.setOutput(
|
||||
'preReleaseNumber',
|
||||
gitversion.PreReleaseNumber.toString()
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'weightedPreReleaseNumber',
|
||||
gitversion.WeightedPreReleaseNumber.toString()
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'buildMetaData',
|
||||
gitversion.BuildMetaData.toString()
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'buildMetaDataPadded',
|
||||
gitversion.BuildMetaDataPadded
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'fullBuildMetaData',
|
||||
gitversion.FullBuildMetaData
|
||||
)
|
||||
this.buildAgent.setOutput('majorMinorPatch', gitversion.MajorMinorPatch)
|
||||
this.buildAgent.setOutput('semVer', gitversion.SemVer)
|
||||
this.buildAgent.setOutput('legacySemVer', gitversion.LegacySemVer)
|
||||
this.buildAgent.setOutput(
|
||||
'legacySemVerPadded',
|
||||
gitversion.LegacySemVerPadded
|
||||
)
|
||||
this.buildAgent.setOutput('assemblySemVer', gitversion.AssemblySemVer)
|
||||
this.buildAgent.setOutput(
|
||||
'assemblySemFileVer',
|
||||
gitversion.AssemblySemFileVer
|
||||
)
|
||||
this.buildAgent.setOutput('fullSemVer', gitversion.FullSemVer)
|
||||
this.buildAgent.setOutput(
|
||||
'informationalVersion',
|
||||
gitversion.InformationalVersion
|
||||
)
|
||||
this.buildAgent.setOutput('branchName', gitversion.BranchName)
|
||||
this.buildAgent.setOutput('sha', gitversion.Sha)
|
||||
this.buildAgent.setOutput('shortSha', gitversion.ShortSha)
|
||||
this.buildAgent.setOutput('nuGetVersionV2', gitversion.NuGetVersionV2)
|
||||
this.buildAgent.setOutput('nuGetVersion', gitversion.NuGetVersion)
|
||||
this.buildAgent.setOutput(
|
||||
'nuGetPreReleaseTagV2',
|
||||
gitversion.NuGetPreReleaseTagV2
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'nuGetPreReleaseTag',
|
||||
gitversion.NuGetPreReleaseTag
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'versionSourceSha',
|
||||
gitversion.VersionSourceSha
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'commitsSinceVersionSource',
|
||||
gitversion.CommitsSinceVersionSource.toString()
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'commitsSinceVersionSourcePadded',
|
||||
gitversion.CommitsSinceVersionSourcePadded
|
||||
)
|
||||
this.buildAgent.setOutput('commitDate', gitversion.CommitDate)
|
||||
let properties = Object.keys(gitversion);
|
||||
let gitversionOutput = <any> gitversion;
|
||||
|
||||
properties.forEach(property => {
|
||||
const name = this.toCamelCase(property)
|
||||
const value = gitversionOutput[property]
|
||||
this.buildAgent.setOutput(name, value);
|
||||
});
|
||||
}
|
||||
|
||||
private toCamelCase(input: string): string {
|
||||
return input.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, index) {
|
||||
if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
|
||||
return index == 0 ? match.toLowerCase() : match.toUpperCase();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user