在Azure管道中访问GitVersion变量以进行JavaScript构建

时间:2019-06-25 09:00:04

标签: azure-devops azure-pipelines azure-pipelines-build-task

我有以下管道:

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 不喜欢。因此,问题在于如何使 not 不会发生。

1 个答案:

答案 0 :(得分:2)

您在SELECT * FROM news WHERE start_at <= NOW() AND (end_at >= NOW() OR end_at IS NULL) 中有一个额外的",只需删除它就可以了:

$(GitVersion.FullSemVer")

例如:

echo '##vso[task.setvariable variable=buildVersion]$(GitVersion.FullSemRev)'

结果:

enter image description here