From 39f0917506abf1a701d01c22fcb092b1369ee75d Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Tue, 10 Dec 2024 16:05:50 +0100 Subject: [PATCH] Add support for dot-delimited GitVersion outputs/variables Expanded the tool to set dot-delimited (`GitVersion.Property`) outputs and variables alongside existing formats. Updated corresponding tests to validate the new format for both outputs and environment variables, ensuring consistency and proper coverage. --- src/__tests__/tools/gitversion/runner.spec.ts | 3 +++ src/__tests__/tools/gitversion/tool.spec.ts | 12 ++++++++++++ src/tools/gitversion/tool.ts | 2 ++ 3 files changed, 17 insertions(+) diff --git a/src/__tests__/tools/gitversion/runner.spec.ts b/src/__tests__/tools/gitversion/runner.spec.ts index c9e57378f..1a99507c7 100644 --- a/src/__tests__/tools/gitversion/runner.spec.ts +++ b/src/__tests__/tools/gitversion/runner.spec.ts @@ -75,6 +75,9 @@ describe('GitVersion Runner', () => { expect(getEnv('GitVersion_Major')).toBeDefined() expect(getEnv('GitVersion_Minor')).toBeDefined() expect(getEnv('GitVersion_Patch')).toBeDefined() + expect(getEnv('GitVersion.Major')).toBeDefined() + expect(getEnv('GitVersion.Minor')).toBeDefined() + expect(getEnv('GitVersion.Patch')).toBeDefined() expect(getEnv('major')).toBeDefined() expect(getEnv('minor')).toBeDefined() diff --git a/src/__tests__/tools/gitversion/tool.spec.ts b/src/__tests__/tools/gitversion/tool.spec.ts index af875e006..6e31e4543 100644 --- a/src/__tests__/tools/gitversion/tool.spec.ts +++ b/src/__tests__/tools/gitversion/tool.spec.ts @@ -86,6 +86,12 @@ describe('GitVersionTool', () => { expect(outputs.get('GitVersion_SemVer')).toBe('1.2.3-alpha.1') expect(outputs.get('GitVersion_FullSemVer')).toBe('1.2.3-alpha.1') + expect(outputs.get('GitVersion.Major')).toBe('1') + expect(outputs.get('GitVersion.Minor')).toBe('2') + expect(outputs.get('GitVersion.Patch')).toBe('3') + expect(outputs.get('GitVersion.SemVer')).toBe('1.2.3-alpha.1') + expect(outputs.get('GitVersion.FullSemVer')).toBe('1.2.3-alpha.1') + expect(variables.get('major')).toBe('1') expect(variables.get('minor')).toBe('2') expect(variables.get('patch')).toBe('3') @@ -97,6 +103,12 @@ describe('GitVersionTool', () => { expect(variables.get('GitVersion_Patch')).toBe('3') expect(variables.get('GitVersion_SemVer')).toBe('1.2.3-alpha.1') expect(variables.get('GitVersion_FullSemVer')).toBe('1.2.3-alpha.1') + + expect(variables.get('GitVersion.Major')).toBe('1') + expect(variables.get('GitVersion.Minor')).toBe('2') + expect(variables.get('GitVersion.Patch')).toBe('3') + expect(variables.get('GitVersion.SemVer')).toBe('1.2.3-alpha.1') + expect(variables.get('GitVersion.FullSemVer')).toBe('1.2.3-alpha.1') }) }) diff --git a/src/tools/gitversion/tool.ts b/src/tools/gitversion/tool.ts index 3e19eeec5..b87af5f8e 100644 --- a/src/tools/gitversion/tool.ts +++ b/src/tools/gitversion/tool.ts @@ -58,8 +58,10 @@ export class GitVersionTool extends DotnetTool { } this.buildAgent.setOutput(name, value) this.buildAgent.setOutput(`GitVersion_${property}`, value) + this.buildAgent.setOutput(`GitVersion.${property}`, value) this.buildAgent.setVariable(name, value) this.buildAgent.setVariable(`GitVersion_${property}`, value) + this.buildAgent.setVariable(`GitVersion.${property}`, value) } catch (_error) { this.buildAgent.error(`Unable to set output/variable for ${property}`) }