Reputation: 939
I've got the following pipeline:
steps:
- task: GitVersion@4
- script: |
echo '##vso[task.setvariable variable=buildVersion]$(GitVersion.FullSemVer")'
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@1
inputs:
command: 'install'
workingDir: '$(Build.SourcesDirectory)'
displayName: "NPM Install"
- task: Npm@1
inputs:
command: 'custom'
workingDir: '$(Build.SourcesDirectory)'
customCommand: 'run-script build'
displayName: "NPM Build"
- task: Npm@1
inputs:
command: 'custom'
workingDir: '$(Build.SourcesDirectory)'
customCommand: 'npm version $(buildVersion)'
displayName: "Add version"
But I can't get access to the GitVersion output. I've tried with simply referencing $(GitVersion.FullSemVer) as well, but it gives the same result. The output from npm version is:
[command]C:\windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\10.16.0\x64\npm.cmd npm version "$(GitVersion.FullSemVer)'""
Usage: npm <command>
If I write out the actual variables it looks fine.
Edit: It seems the problem at hand is that the version number is quoted, which npm doesn't like. So the question is more how to make that not happen.
Upvotes: 0
Views: 2158
Reputation: 41595
You have an extra "
in $(GitVersion.FullSemVer")
, just remove it and it will be fine:
echo '##vso[task.setvariable variable=buildVersion]$(GitVersion.FullSemVer)'
For example:
- task: GitVersion@4
- script: 'echo ##vso[setvariable variable=buildVersion]$(GitVersion.FullSemVer)'
- script: 'echo $(buildVersion)'
Results:
Upvotes: 2