我有以下管道:
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"
但我无法访问 GitVersion 输出。我也尝试过简单地引用 $(GitVersion.FullSemVer) ,但它给出了相同的结果。 npm 版本的输出是:
[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>
如果我写出实际变量,它看起来不错。
编辑: 看来手头的问题是版本号被引用,这是 npm 不喜欢的。所以问题更多的是如何让这种“不”发生。