【问题标题】:Azure CI and CD with NBGV带有 NBGV 的 Azure CI 和 CD
【发布时间】:2020-09-24 11:27:40
【问题描述】:

我们在 CI 管道中使用 NB.GV,例如:

- task: DotNetCoreCLI@2
  inputs:
    command: custom
    custom: tool
    arguments: install --tool-path . nbgv --ignore-failed-sources
  displayName: Install NBGV tool

- script: nbgv cloud -c -a
  displayName: Set Version

它正确设置了版本,因此在进一步的任务中,我们可以使用它们(例如 $(GitBuildVersion))

当我们尝试根据this 文章设置 CD 管道时,问题就出现了。在那里我们需要读取$(Build.BuildNumber),它的值与预期的不同。基于official documentation 它应该是例如1.3.1.57621,但我们得到的是 1.3.1+g15e1898f47

似乎 AssemblyInformationalVersionBuildVersion 交换了。

我们在 version.json 中设置了setVersionVariables: true

提前感谢您的帮助

【问题讨论】:

  • NGBV 设置 BuildNumber,这就是这个工具的作用。那么您能解释一下您在这里遇到的具体问题吗?
  • 在我们的例子中,它在 CD(发行版)中错误地设置了 BuildNumber。我们期待像 1.3.1.57621 这样的东西,但我们得到的是 1.3.1+g15e1898f47。需要提到的是,在整个 CI 管道中是可以的。开始新版本时,BuildNumber 设置为 1.3.1+g15e1898f47 而不是应为的 1.3.1.57621

标签: azure-devops azure-pipelines versioning


【解决方案1】:

你在运行 ngbv 后添加这个来更新你的 BuildNumber

      - powershell: Write-Host "##vso[build.updatebuildnumber]$(GitBuildVersion)"
        displayName: 'Update build number to $(GitBuildVersion)'

据此,您应该具有预期值:

你也可以通过运行- bash: env | sort来检查你有哪些变量

【讨论】:

    猜你喜欢
    • 2018-03-16
    • 2020-07-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-22
    • 1970-01-01
    • 1970-01-01
    • 2019-10-26
    • 2020-08-12
    相关资源
    最近更新 更多