From c0466a77ff5a15e996f2587b3b370e25defd1e3f Mon Sep 17 00:00:00 2001 From: Artur Date: Sat, 11 Mar 2023 17:21:01 +0100 Subject: [PATCH] test the output and variables --- .azure/ci.yml | 11 +++++++++-- .github/workflows/ci.yml | 6 +++++- src/agent/azure/build-agent.ts | 6 +++--- src/agent/github/build-agent.ts | 3 +-- src/agent/mock/build-agent.ts | 4 ++-- src/core/dotnet-tool.ts | 6 +++--- src/core/models.ts | 2 +- src/tools/gitversion/tool.ts | 3 +++ 8 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.azure/ci.yml b/.azure/ci.yml index 7c12849..31acb65 100644 --- a/.azure/ci.yml +++ b/.azure/ci.yml @@ -28,9 +28,16 @@ steps: npm run format-check npm run build:azure displayName: 'Build code' - - bash: 'INPUT_VERSIONSPEC=$(INPUT_VERSIONSPEC) node ./gitversion/setup/bundle.js' + - pwsh: $env:INPUT_VERSIONSPEC = "$(INPUT_VERSIONSPEC)"; node ./gitversion/setup/bundle.js displayName: gitversion/setup workingDirectory: dist/azure - - bash: 'node ./gitversion/execute/bundle.js' + - pwsh: node ./gitversion/execute/bundle.js + name: version displayName: gitversion/execute workingDirectory: dist/azure + - pwsh: | + echo "FullSemVer (fullSemVer) : $(fullSemVer)" + echo "FullSemVer (GitVersion_FullSemVer) : $(GitVersion_FullSemVer)" + echo "FullSemVer (version.fullSemVer) : $(version.fullSemVer)" + echo "FullSemVer (version.GitVersion_FullSemVer) : $(version.GitVersion_FullSemVer)" + displayName: Use variables and output diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2aecc4a..10f1584 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,4 +34,8 @@ jobs: id: gitversion # step id used as reference for output values uses: ./gitversion/execute - run: | - echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}" + echo "FullSemVer (env.fullSemVer) : ${{ env.fullSemVer }}" + echo "FullSemVer (env.GitVersion_FullSemVer) : ${{ env.GitVersion_FullSemVer }}" + echo "FullSemVer (steps.gitversion.outputs.fullSemVer) : ${{ steps.gitversion.outputs.fullSemVer }}" + echo "FullSemVer (steps.gitversion.outputs.GitVersion_FullSemVer) : ${{ steps.gitversion.outputs.GitVersion_FullSemVer }}" + name: Use variables and output diff --git a/src/agent/azure/build-agent.ts b/src/agent/azure/build-agent.ts index 5d19a73..105655d 100644 --- a/src/agent/azure/build-agent.ts +++ b/src/agent/azure/build-agent.ts @@ -44,8 +44,8 @@ class BuildAgent implements IBuildAgent { taskLib.setResult(taskLib.TaskResult.Succeeded, message, done) } - public exportVariable(name: string, val: string): void { - taskLib.setVariable(name, val) + public setVariable(name: string, value: string): void { + taskLib.setVariable(name, value) } public getVariable(name: string): string { @@ -78,7 +78,7 @@ class BuildAgent implements IBuildAgent { } public setOutput(name: string, value: string): void { - taskLib.setVariable(name, value) + taskLib.setVariable(name, value, false, true) } public getInput(input: string, required?: boolean): string { diff --git a/src/agent/github/build-agent.ts b/src/agent/github/build-agent.ts index c109faf..c7bbb05 100644 --- a/src/agent/github/build-agent.ts +++ b/src/agent/github/build-agent.ts @@ -110,7 +110,7 @@ class BuildAgent implements IBuildAgent { // } - public exportVariable(name: string, val: string): void { + public setVariable(name: string, val: string): void { core.exportVariable(name, val) } @@ -155,7 +155,6 @@ class BuildAgent implements IBuildAgent { public setOutput(name: string, value: string): void { core.setOutput(name, value) - core.exportVariable(`GITVERSION_${name.toUpperCase()}`, value) } public getInput(input: string, required?: boolean): string { diff --git a/src/agent/mock/build-agent.ts b/src/agent/mock/build-agent.ts index 34119e8..dc7b2df 100644 --- a/src/agent/mock/build-agent.ts +++ b/src/agent/mock/build-agent.ts @@ -41,8 +41,8 @@ class BuildAgent implements IBuildAgent { console.log('setSucceeded') } - public exportVariable(name: string, val: string): void { - console.log('exportVariable') + public setVariable(name: string, val: string): void { + console.log('setVariable') } public getVariable(name: string): string { diff --git a/src/core/dotnet-tool.ts b/src/core/dotnet-tool.ts index df35e21..51b97c0 100644 --- a/src/core/dotnet-tool.ts +++ b/src/core/dotnet-tool.ts @@ -28,8 +28,8 @@ export class DotnetTool implements IDotnetTool { } public disableTelemetry(): void { - this.buildAgent.exportVariable('DOTNET_CLI_TELEMETRY_OPTOUT', 'true') - this.buildAgent.exportVariable('DOTNET_NOLOGO', 'true') + this.buildAgent.setVariable('DOTNET_CLI_TELEMETRY_OPTOUT', 'true') + this.buildAgent.setVariable('DOTNET_NOLOGO', 'true') } public execute(cmd: string, args: string[]): Promise { @@ -102,7 +102,7 @@ export class DotnetTool implements IDotnetTool { let dotnetPath = await this.buildAgent.which('dotnet') dotnetPath = fs.readlinkSync(dotnetPath) || dotnetPath const dotnetRoot = path.dirname(dotnetPath) - this.buildAgent.exportVariable('DOTNET_ROOT', dotnetRoot) + this.buildAgent.setVariable('DOTNET_ROOT', dotnetRoot) } this.buildAgent.addPath(toolPath) diff --git a/src/core/models.ts b/src/core/models.ts index 29fffa0..194fe6c 100644 --- a/src/core/models.ts +++ b/src/core/models.ts @@ -25,7 +25,7 @@ export interface IBuildAgent { debug(message: string): void setFailed(message: string, done?: boolean): void setSucceeded(message: string, done?: boolean): void - exportVariable(name: string, val: string): void + setVariable(name: string, val: string): void getVariable(name: string): string addPath(inputPath: string): void which(tool: string, check?: boolean): Promise diff --git a/src/tools/gitversion/tool.ts b/src/tools/gitversion/tool.ts index 3161e21..09c7054 100644 --- a/src/tools/gitversion/tool.ts +++ b/src/tools/gitversion/tool.ts @@ -83,6 +83,9 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool { const name = this.toCamelCase(property) const value = gitversionOutput[property] this.buildAgent.setOutput(name, value) + this.buildAgent.setOutput(`GitVersion_${name}`, value) + this.buildAgent.setVariable(name, value) + this.buildAgent.setVariable(`GitVersion_${name}`, value) }) }