Доступ к переменной GitVersion в конвейере Azure для сборки javascript - PullRequest
0 голосов
/ 25 июня 2019

У меня есть следующий конвейер:

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 не нравится. Таким образом, вопрос заключается в том, как сделать так, чтобы не произошло.

1 Ответ

2 голосов
/ 25 июня 2019

У вас есть дополнительные " в $(GitVersion.FullSemVer"), просто удалите их, и все будет в порядке:

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

Например:

- task: GitVersion@4

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

- script: 'echo $(buildVersion)'

Результаты:

enter image description here

...