diff --git a/dist/tools/libs/gitversion.mjs b/dist/tools/libs/gitversion.mjs index 37ff6045b..223e3481d 100644 --- a/dist/tools/libs/gitversion.mjs +++ b/dist/tools/libs/gitversion.mjs @@ -82,8 +82,10 @@ 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}`); } diff --git a/dist/tools/libs/gitversion.mjs.map b/dist/tools/libs/gitversion.mjs.map index 0dd10b1ab..126e10a3b 100644 --- a/dist/tools/libs/gitversion.mjs.map +++ b/dist/tools/libs/gitversion.mjs.map @@ -1 +1 @@ -{"version":3,"file":"gitversion.mjs","sources":["../../../src/tools/gitversion/settings.ts","../../../src/tools/gitversion/tool.ts","../../../src/tools/gitversion/runner.ts"],"sourcesContent":["import { type ISettingsProvider, SettingsProvider } from '@tools/common'\nimport { type CommandSettings, type ExecuteSettings } from './models'\n\nexport interface IGitVersionSettingsProvider extends ISettingsProvider {\n getExecuteSettings(): ExecuteSettings\n\n getCommandSettings(): CommandSettings\n}\n\nexport class GitVersionSettingsProvider extends SettingsProvider implements IGitVersionSettingsProvider {\n getExecuteSettings(): ExecuteSettings {\n const targetPath = this.buildAgent.getInput('targetPath')\n\n const disableCache = this.buildAgent.getBooleanInput('disableCache')\n const disableNormalization = this.buildAgent.getBooleanInput('disableNormalization')\n const disableShallowCloneCheck = this.buildAgent.getBooleanInput('disableShallowCloneCheck')\n\n const useConfigFile = this.buildAgent.getBooleanInput('useConfigFile')\n const configFilePath = this.buildAgent.getInput('configFilePath')\n const overrideConfig = this.buildAgent.getListInput('overrideConfig')\n\n const updateAssemblyInfo = this.buildAgent.getBooleanInput('updateAssemblyInfo')\n const updateAssemblyInfoFilename = this.buildAgent.getInput('updateAssemblyInfoFilename')\n\n return {\n targetPath,\n disableCache,\n disableNormalization,\n disableShallowCloneCheck,\n useConfigFile,\n configFilePath,\n overrideConfig,\n updateAssemblyInfo,\n updateAssemblyInfoFilename\n }\n }\n\n getCommandSettings(): CommandSettings {\n const targetPath = this.buildAgent.getInput('targetPath')\n const disableShallowCloneCheck = this.buildAgent.getBooleanInput('disableShallowCloneCheck')\n const args = this.buildAgent.getInput('arguments')\n\n return {\n targetPath,\n disableShallowCloneCheck,\n arguments: args\n }\n }\n}\n","import { type ExecResult } from '@agents/common'\nimport { DotnetTool, keysOf } from '@tools/common'\nimport { type CommandSettings, type ExecuteSettings, type GitVersionOutput } from './models'\nimport { GitVersionSettingsProvider, type IGitVersionSettingsProvider } from './settings'\n\nexport class GitVersionTool extends DotnetTool {\n get packageName(): string {\n return 'GitVersion.Tool'\n }\n\n get toolName(): string {\n return 'dotnet-gitversion'\n }\n\n get toolPathVariable(): string {\n return 'GITVERSION_PATH'\n }\n\n get versionRange(): string | null {\n return '>=5.2.0 <6.1.0'\n }\n\n get settingsProvider(): IGitVersionSettingsProvider {\n return new GitVersionSettingsProvider(this.buildAgent)\n }\n\n async executeJson(): Promise {\n const settings = this.settingsProvider.getExecuteSettings()\n const workDir = await this.getRepoDir(settings)\n\n await this.checkShallowClone(settings, workDir)\n\n const args = await this.getExecuteArguments(workDir, settings)\n\n await this.setDotnetRoot()\n return await this.executeTool(args)\n }\n\n async executeCommand(): Promise {\n const settings = this.settingsProvider.getCommandSettings()\n const workDir = await this.getRepoDir(settings)\n\n await this.checkShallowClone(settings, workDir)\n\n const args = this.getCommandArguments(workDir, settings)\n\n await this.setDotnetRoot()\n return await this.executeTool(args)\n }\n\n writeGitVersionToAgent(output: GitVersionOutput): void {\n for (const property of keysOf(output)) {\n const name = this.toCamelCase(property)\n try {\n let value = output[property]?.toString()\n if (value === '0') {\n value = '0'\n }\n this.buildAgent.setOutput(name, value)\n this.buildAgent.setOutput(`GitVersion_${property}`, value)\n this.buildAgent.setVariable(name, value)\n this.buildAgent.setVariable(`GitVersion_${property}`, value)\n } catch (_error) {\n this.buildAgent.error(`Unable to set output/variable for ${property}`)\n }\n }\n\n if (output.FullSemVer.endsWith('+0')) {\n output.FullSemVer = output.FullSemVer.slice(0, -2)\n }\n this.buildAgent.updateBuildNumber(output.FullSemVer)\n }\n\n protected async getRepoDir(settings: ExecuteSettings | CommandSettings): Promise {\n return await super.getRepoPath(settings.targetPath)\n }\n\n protected async getExecuteArguments(workDir: string, options: ExecuteSettings): Promise {\n const args = [workDir, '/output', 'json', '/l', 'console']\n\n const {\n useConfigFile,\n disableCache,\n disableNormalization,\n configFilePath,\n overrideConfig,\n updateAssemblyInfo,\n updateAssemblyInfoFilename\n //\n } = options\n\n if (disableCache) {\n args.push('/nocache')\n }\n\n if (disableNormalization) {\n args.push('/nonormalize')\n }\n\n if (useConfigFile) {\n if (await this.isValidInputFile('configFilePath', configFilePath)) {\n args.push('/config', configFilePath)\n } else {\n throw new Error(`GitVersion configuration file not found at ${configFilePath}`)\n }\n }\n\n if (overrideConfig) {\n for (let config of overrideConfig) {\n config = config.trim()\n if (config.match(/([a-zA-Z0-9]+(-[a-zA-Z]+)*=[a-zA-Z0-9\\- :.']*)/)) {\n args.push('/overrideconfig', config)\n }\n }\n }\n\n if (updateAssemblyInfo) {\n args.push('/updateassemblyinfo')\n\n // You can specify 'updateAssemblyInfo' without 'updateAssemblyInfoFilename'.\n if (updateAssemblyInfoFilename?.length > 0) {\n if (await this.isValidInputFile('updateAssemblyInfoFilename', updateAssemblyInfoFilename)) {\n args.push(updateAssemblyInfoFilename)\n } else {\n throw new Error(`AssemblyInfoFilename file not found at ${updateAssemblyInfoFilename}`)\n }\n }\n }\n\n return args\n }\n\n protected getCommandArguments(workDir: string, options: CommandSettings): string[] {\n let args = [workDir]\n\n if (options.arguments) {\n args = args.concat(this.argStringToArray(options.arguments))\n }\n return args\n }\n\n private argStringToArray(argString: string): string[] {\n const args: string[] = []\n\n let inQuotes = false\n let escaped = false\n let lastCharWasSpace = true\n let arg = ''\n\n const append = (c: string): void => {\n // we only escape double quotes.\n if (escaped && c !== '\"') {\n arg += '\\\\'\n }\n\n arg += c\n escaped = false\n }\n\n for (let i = 0; i < argString.length; i++) {\n const c = argString.charAt(i)\n\n if (c === ' ' && !inQuotes) {\n if (!lastCharWasSpace) {\n args.push(arg)\n arg = ''\n }\n lastCharWasSpace = true\n continue\n } else {\n lastCharWasSpace = false\n }\n\n if (c === '\"') {\n if (!escaped) {\n inQuotes = !inQuotes\n } else {\n append(c)\n }\n continue\n }\n\n if (c === '\\\\' && escaped) {\n append(c)\n continue\n }\n\n if (c === '\\\\' && inQuotes) {\n escaped = true\n continue\n }\n\n append(c)\n lastCharWasSpace = false\n }\n\n if (!lastCharWasSpace) {\n args.push(arg.trim())\n }\n\n return args\n }\n\n private async checkShallowClone(settings: ExecuteSettings | CommandSettings, workDir: string): Promise {\n if (!settings.disableShallowCloneCheck) {\n const isShallowResult = await this.execute('git', ['-C', workDir, 'rev-parse', '--is-shallow-repository'])\n if (isShallowResult.code === 0 && isShallowResult.stdout?.trim() === 'true') {\n throw new Error(\n 'The repository is shallow. Consider disabling shallow clones. See https://github.com/GitTools/actions/blob/main/docs/cloning.md for more information.'\n )\n }\n }\n }\n\n private toCamelCase(input: string): string {\n return input.replace(/^\\w|[A-Z]|\\b\\w|\\s+/g, function (match, index) {\n if (+match === 0) return '' // or if (/\\s+/.test(match)) for white spaces\n return index === 0 ? match.toLowerCase() : match.toUpperCase()\n })\n }\n}\n","import { type ExecResult, type IBuildAgent } from '@agents/common'\nimport { type Commands, type GitVersionOutput } from './models'\nimport { GitVersionTool } from './tool'\nimport { RunnerBase } from '../common/runner'\n\nexport class Runner extends RunnerBase {\n protected readonly tool: GitVersionTool\n\n constructor(protected readonly buildAgent: IBuildAgent) {\n super(buildAgent)\n this.tool = new GitVersionTool(this.buildAgent)\n }\n\n async run(command: Commands): Promise {\n switch (command) {\n case 'setup':\n return await this.setup()\n case 'execute':\n return await this.execute()\n case 'command':\n return await this.command()\n }\n }\n\n private async setup(): Promise {\n return this.safeExecute(async () => {\n await this.tool.install()\n return { code: 0 }\n }, 'GitVersion setup successfully')\n }\n\n private async execute(): Promise {\n return this.safeExecute(async () => {\n const result = await this.tool.executeJson()\n this.buildAgent.debug('Parsing GitVersion output')\n return this.processGitVersionOutput(result)\n }, 'GitVersion executed successfully')\n }\n\n private async command(): Promise {\n return this.safeExecute(async () => await this.tool.executeCommand(), 'GitVersion executed successfully')\n }\n\n private processGitVersionOutput(result: ExecResult): ExecResult {\n const stdout = result.stdout as string\n if (stdout.lastIndexOf('{') === -1 || stdout.lastIndexOf('}') === -1) {\n this.buildAgent.debug('GitVersion output is not valid JSON')\n this.buildAgent.setFailed('GitVersion output is not valid JSON', true)\n return {\n code: -1,\n error: new Error('GitVersion output is not valid JSON')\n }\n } else {\n const jsonOutput = stdout.substring(stdout.lastIndexOf('{'), stdout.lastIndexOf('}') + 1)\n\n const gitVersionOutput = JSON.parse(jsonOutput) as GitVersionOutput\n this.tool.writeGitVersionToAgent(gitVersionOutput)\n this.buildAgent.setSucceeded('GitVersion executed successfully', true)\n return result\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;AASO,MAAM,mCAAmC,gBAAwD,CAAA;AAAA,EACpG,kBAAsC,GAAA;AAClC,IAAA,MAAM,UAAa,GAAA,IAAA,CAAK,UAAW,CAAA,QAAA,CAA0B,YAAY,CAAA;AAEzE,IAAA,MAAM,YAAe,GAAA,IAAA,CAAK,UAAW,CAAA,eAAA,CAAiC,cAAc,CAAA;AACpF,IAAA,MAAM,oBAAuB,GAAA,IAAA,CAAK,UAAW,CAAA,eAAA,CAAiC,sBAAsB,CAAA;AACpG,IAAA,MAAM,wBAA2B,GAAA,IAAA,CAAK,UAAW,CAAA,eAAA,CAAiC,0BAA0B,CAAA;AAE5G,IAAA,MAAM,aAAgB,GAAA,IAAA,CAAK,UAAW,CAAA,eAAA,CAAiC,eAAe,CAAA;AAC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A;AAAA,QACH,IAAM,EAAA,CAAA,CAAA;AAAA,QACN,KAAA,EAAO,IAAI,KAAA,CAAM,qCAAqC;AAAA,OAC1D;AAAA,KACG,MAAA;AACH,MAAM,MAAA,UAAA,GAAa,MAAO,CAAA,SAAA,CAAU,MAAO,CAAA,WAAA,CAAY,GAAG,CAAA,EAAG,MAAO,CAAA,WAAA,CAAY,GAAG,CAAA,GAAI,CAAC,CAAA;AAExF,MAAM,MAAA,gBAAA,GAAmB,IAAK,CAAA,KAAA,CAAM,UAAU,CAAA;AAC9C,MAAK,IAAA,CAAA,IAAA,CAAK,uBAAuB,gBAAgB,CAAA;AACjD,MAAK,IAAA,CAAA,UAAA,CAAW,YAAa,CAAA,kCAAA,EAAoC,IAAI,CAAA;AACrE,MAAO,OAAA,MAAA;AAAA;AACX;AAER;;;;"} \ No newline at end of file +{"version":3,"file":"gitversion.mjs","sources":["../../../src/tools/gitversion/settings.ts","../../../src/tools/gitversion/tool.ts","../../../src/tools/gitversion/runner.ts"],"sourcesContent":["import { type ISettingsProvider, SettingsProvider } from '@tools/common'\nimport { type CommandSettings, type ExecuteSettings } from './models'\n\nexport interface IGitVersionSettingsProvider extends ISettingsProvider {\n getExecuteSettings(): ExecuteSettings\n\n getCommandSettings(): CommandSettings\n}\n\nexport class GitVersionSettingsProvider extends SettingsProvider implements IGitVersionSettingsProvider {\n getExecuteSettings(): ExecuteSettings {\n const targetPath = this.buildAgent.getInput('targetPath')\n\n const disableCache = this.buildAgent.getBooleanInput('disableCache')\n const disableNormalization = this.buildAgent.getBooleanInput('disableNormalization')\n const disableShallowCloneCheck = this.buildAgent.getBooleanInput('disableShallowCloneCheck')\n\n const useConfigFile = this.buildAgent.getBooleanInput('useConfigFile')\n const configFilePath = this.buildAgent.getInput('configFilePath')\n const overrideConfig = this.buildAgent.getListInput('overrideConfig')\n\n const updateAssemblyInfo = this.buildAgent.getBooleanInput('updateAssemblyInfo')\n const updateAssemblyInfoFilename = this.buildAgent.getInput('updateAssemblyInfoFilename')\n\n return {\n targetPath,\n disableCache,\n disableNormalization,\n disableShallowCloneCheck,\n useConfigFile,\n configFilePath,\n overrideConfig,\n updateAssemblyInfo,\n updateAssemblyInfoFilename\n }\n }\n\n getCommandSettings(): CommandSettings {\n const targetPath = this.buildAgent.getInput('targetPath')\n const disableShallowCloneCheck = this.buildAgent.getBooleanInput('disableShallowCloneCheck')\n const args = this.buildAgent.getInput('arguments')\n\n return {\n targetPath,\n disableShallowCloneCheck,\n arguments: args\n }\n }\n}\n","import { type ExecResult } from '@agents/common'\nimport { DotnetTool, keysOf } from '@tools/common'\nimport { type CommandSettings, type ExecuteSettings, type GitVersionOutput } from './models'\nimport { GitVersionSettingsProvider, type IGitVersionSettingsProvider } from './settings'\n\nexport class GitVersionTool extends DotnetTool {\n get packageName(): string {\n return 'GitVersion.Tool'\n }\n\n get toolName(): string {\n return 'dotnet-gitversion'\n }\n\n get toolPathVariable(): string {\n return 'GITVERSION_PATH'\n }\n\n get versionRange(): string | null {\n return '>=5.2.0 <6.1.0'\n }\n\n get settingsProvider(): IGitVersionSettingsProvider {\n return new GitVersionSettingsProvider(this.buildAgent)\n }\n\n async executeJson(): Promise {\n const settings = this.settingsProvider.getExecuteSettings()\n const workDir = await this.getRepoDir(settings)\n\n await this.checkShallowClone(settings, workDir)\n\n const args = await this.getExecuteArguments(workDir, settings)\n\n await this.setDotnetRoot()\n return await this.executeTool(args)\n }\n\n async executeCommand(): Promise {\n const settings = this.settingsProvider.getCommandSettings()\n const workDir = await this.getRepoDir(settings)\n\n await this.checkShallowClone(settings, workDir)\n\n const args = this.getCommandArguments(workDir, settings)\n\n await this.setDotnetRoot()\n return await this.executeTool(args)\n }\n\n writeGitVersionToAgent(output: GitVersionOutput): void {\n for (const property of keysOf(output)) {\n const name = this.toCamelCase(property)\n try {\n let value = output[property]?.toString()\n if (value === '0') {\n value = '0'\n }\n this.buildAgent.setOutput(name, value)\n this.buildAgent.setOutput(`GitVersion_${property}`, value)\n this.buildAgent.setOutput(`GitVersion.${property}`, value)\n this.buildAgent.setVariable(name, value)\n this.buildAgent.setVariable(`GitVersion_${property}`, value)\n this.buildAgent.setVariable(`GitVersion.${property}`, value)\n } catch (_error) {\n this.buildAgent.error(`Unable to set output/variable for ${property}`)\n }\n }\n\n if (output.FullSemVer.endsWith('+0')) {\n output.FullSemVer = output.FullSemVer.slice(0, -2)\n }\n this.buildAgent.updateBuildNumber(output.FullSemVer)\n }\n\n protected async getRepoDir(settings: ExecuteSettings | CommandSettings): Promise {\n return await super.getRepoPath(settings.targetPath)\n }\n\n protected async getExecuteArguments(workDir: string, options: ExecuteSettings): Promise {\n const args = [workDir, '/output', 'json', '/l', 'console']\n\n const {\n useConfigFile,\n disableCache,\n disableNormalization,\n configFilePath,\n overrideConfig,\n updateAssemblyInfo,\n updateAssemblyInfoFilename\n //\n } = options\n\n if (disableCache) {\n args.push('/nocache')\n }\n\n if (disableNormalization) {\n args.push('/nonormalize')\n }\n\n if (useConfigFile) {\n if (await this.isValidInputFile('configFilePath', configFilePath)) {\n args.push('/config', configFilePath)\n } else {\n throw new Error(`GitVersion configuration file not found at ${configFilePath}`)\n }\n }\n\n if (overrideConfig) {\n for (let config of overrideConfig) {\n config = config.trim()\n if (config.match(/([a-zA-Z0-9]+(-[a-zA-Z]+)*=[a-zA-Z0-9\\- :.']*)/)) {\n args.push('/overrideconfig', config)\n }\n }\n }\n\n if (updateAssemblyInfo) {\n args.push('/updateassemblyinfo')\n\n // You can specify 'updateAssemblyInfo' without 'updateAssemblyInfoFilename'.\n if (updateAssemblyInfoFilename?.length > 0) {\n if (await this.isValidInputFile('updateAssemblyInfoFilename', updateAssemblyInfoFilename)) {\n args.push(updateAssemblyInfoFilename)\n } else {\n throw new Error(`AssemblyInfoFilename file not found at ${updateAssemblyInfoFilename}`)\n }\n }\n }\n\n return args\n }\n\n protected getCommandArguments(workDir: string, options: CommandSettings): string[] {\n let args = [workDir]\n\n if (options.arguments) {\n args = args.concat(this.argStringToArray(options.arguments))\n }\n return args\n }\n\n private argStringToArray(argString: string): string[] {\n const args: string[] = []\n\n let inQuotes = false\n let escaped = false\n let lastCharWasSpace = true\n let arg = ''\n\n const append = (c: string): void => {\n // we only escape double quotes.\n if (escaped && c !== '\"') {\n arg += '\\\\'\n }\n\n arg += c\n escaped = false\n }\n\n for (let i = 0; i < argString.length; i++) {\n const c = argString.charAt(i)\n\n if (c === ' ' && !inQuotes) {\n if (!lastCharWasSpace) {\n args.push(arg)\n arg = ''\n }\n lastCharWasSpace = true\n continue\n } else {\n lastCharWasSpace = false\n }\n\n if (c === '\"') {\n if (!escaped) {\n inQuotes = !inQuotes\n } else {\n append(c)\n }\n continue\n }\n\n if (c === '\\\\' && escaped) {\n append(c)\n continue\n }\n\n if (c === '\\\\' && inQuotes) {\n escaped = true\n continue\n }\n\n append(c)\n lastCharWasSpace = false\n }\n\n if (!lastCharWasSpace) {\n args.push(arg.trim())\n }\n\n return args\n }\n\n private async checkShallowClone(settings: ExecuteSettings | CommandSettings, workDir: string): Promise {\n if (!settings.disableShallowCloneCheck) {\n const isShallowResult = await this.execute('git', ['-C', workDir, 'rev-parse', '--is-shallow-repository'])\n if (isShallowResult.code === 0 && isShallowResult.stdout?.trim() === 'true') {\n throw new Error(\n 'The repository is shallow. Consider disabling shallow clones. See https://github.com/GitTools/actions/blob/main/docs/cloning.md for more information.'\n )\n }\n }\n }\n\n private toCamelCase(input: string): string {\n return input.replace(/^\\w|[A-Z]|\\b\\w|\\s+/g, function (match, index) {\n if (+match === 0) return '' // or if (/\\s+/.test(match)) for white spaces\n return index === 0 ? match.toLowerCase() : match.toUpperCase()\n })\n }\n}\n","import { type ExecResult, type IBuildAgent } from '@agents/common'\nimport { type Commands, type GitVersionOutput } from './models'\nimport { GitVersionTool } from './tool'\nimport { RunnerBase } from '../common/runner'\n\nexport class Runner extends RunnerBase {\n protected readonly tool: GitVersionTool\n\n constructor(protected readonly buildAgent: IBuildAgent) {\n super(buildAgent)\n this.tool = new GitVersionTool(this.buildAgent)\n }\n\n async run(command: Commands): Promise {\n switch (command) {\n case 'setup':\n return await this.setup()\n case 'execute':\n return await this.execute()\n case 'command':\n return await this.command()\n }\n }\n\n private async setup(): Promise {\n return this.safeExecute(async () => {\n await this.tool.install()\n return { code: 0 }\n }, 'GitVersion setup successfully')\n }\n\n private async execute(): Promise {\n return this.safeExecute(async () => {\n const result = await this.tool.executeJson()\n this.buildAgent.debug('Parsing GitVersion output')\n return this.processGitVersionOutput(result)\n }, 'GitVersion executed successfully')\n }\n\n private async command(): Promise {\n return this.safeExecute(async () => await this.tool.executeCommand(), 'GitVersion executed successfully')\n }\n\n private processGitVersionOutput(result: ExecResult): ExecResult {\n const stdout = result.stdout as string\n if (stdout.lastIndexOf('{') === -1 || stdout.lastIndexOf('}') === -1) {\n this.buildAgent.debug('GitVersion output is not valid JSON')\n this.buildAgent.setFailed('GitVersion output is not valid JSON', true)\n return {\n code: -1,\n error: new Error('GitVersion output is not valid JSON')\n }\n } else {\n const jsonOutput = stdout.substring(stdout.lastIndexOf('{'), stdout.lastIndexOf('}') + 1)\n\n const gitVersionOutput = JSON.parse(jsonOutput) as GitVersionOutput\n this.tool.writeGitVersionToAgent(gitVersionOutput)\n this.buildAgent.setSucceeded('GitVersion executed successfully', true)\n return result\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;AASO,MAAM,mCAAmC,gBAAwD,CAAA;AAAA,EACpG,kBAAsC,GAAA;AAClC,IAAA,MAAM,UAAa,GAAA,IAAA,CAAK,UAAW,CAAA,QAAA,CAA0B,YAAY,CAAA;AAEzE,IAAA,MAAM,YAAe,GAAA,IAAA,CAAK,UAAW,CAAA,eAAA,CAAiC,cAAc,CAAA;AACpF,IAAA,MAAM,oBAAuB,GAAA,IAAA,CAAK,UAAW,CAAA,eAAA,CAAiC,sBAAsB,CAAA;AACpG,IAAA,MAAM,wBAA2B,GAAA,IAAA,CAAK,UAAW,CAAA,eAAA,CAAiC,0BAA0B,CAAA;AAE5G,IAAA,MAAM,aA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A,CAAO,YAAY,GAAG,CAAA,KAAM,MAAM,MAAO,CAAA,WAAA,CAAY,GAAG,CAAA,KAAM,CAAI,CAAA,EAAA;AAClE,MAAK,IAAA,CAAA,UAAA,CAAW,MAAM,qCAAqC,CAAA;AAC3D,MAAK,IAAA,CAAA,UAAA,CAAW,SAAU,CAAA,qCAAA,EAAuC,IAAI,CAAA;AACrE,MAAO,OAAA;AAAA,QACH,IAAM,EAAA,CAAA,CAAA;AAAA,QACN,KAAA,EAAO,IAAI,KAAA,CAAM,qCAAqC;AAAA,OAC1D;AAAA,KACG,MAAA;AACH,MAAM,MAAA,UAAA,GAAa,MAAO,CAAA,SAAA,CAAU,MAAO,CAAA,WAAA,CAAY,GAAG,CAAA,EAAG,MAAO,CAAA,WAAA,CAAY,GAAG,CAAA,GAAI,CAAC,CAAA;AAExF,MAAM,MAAA,gBAAA,GAAmB,IAAK,CAAA,KAAA,CAAM,UAAU,CAAA;AAC9C,MAAK,IAAA,CAAA,IAAA,CAAK,uBAAuB,gBAAgB,CAAA;AACjD,MAAK,IAAA,CAAA,UAAA,CAAW,YAAa,CAAA,kCAAA,EAAoC,IAAI,CAAA;AACrE,MAAO,OAAA,MAAA;AAAA;AACX;AAER;;;;"} \ No newline at end of file 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}`) }