未使用Nerdbank.GitVersioning和Gitlab CI

时间:2018-07-25 12:29:28

标签: gitlab versioning gitlab-ci

我正在使用Nuget包Nerdbank.GitVersioning来对我的C#.Net DLL项目进行版本控制,并且都适用于本地版本(在VS2017中试用)。

但是,当我尝试使用Gitlab运行程序获取要在Nuget打包步骤中使用的版本号时,无论我的version.json文件和/或使用nbgv云工具如何,都没有设置任何环境变量

我的version.json文件如下所示,位于存储库的根目录中;

{
  "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
  "version": "2.0",
  "cloudBuild": {
    "setVersionVariables": true,
    "setAllVariables": true,
    "buildNumber": {
      "enabled": false,
      "includeCommitId": {
        "when": "nonPublicReleaseOnly",
        "where": "buildMetadata"
      }
    }
  }
}

我的.gitlab-ci.yml文件看起来像这样;

#Windows Configuration    

variables:
  GIT_SUBMODULE_STRATEGY: "normal"
  URL: "https://localhost/repository/nuget-hosted"

before_script:
    - echo "Restoring nuget packages"
    - 'nuget restore MyProject.sln'
    #- echo "Installing NB.GV - GitVersioning Tool"
    - dotnet tool install --tool-path . nbgv


vs-15-2017-release-develop-build:
  stage: deploy
  script:
    - echo "Building in Release mode"
    - 'msbuild my-project.sln /p:Configuration=Release /p:PublicRelease=true'
    - echo "Testing in Release mode"
    - 'VSTest.Console.exe build/Release/MyProject.Test/MyProject.Test.dll'
    - echo "deploying build to internal nuget"
    - .\nbgv cloud
    - set #output all env variables for debug
    - nuget pack build/Release/MyProject/MyProject.nuspec -Version %BuildVersion% -Verbosity detailed
    - nuget push MyProject.%VERSION%.nupkg -source %URL% -apikey [removed]
  tags:
    - vs-15-2017

我尝试了各种不同的设置cloudBuild参数的组合,但是没有任何变量将变量输出到环境。

(可能是相关的)第二个问题是设置

buildNumber.enabled = true
不会同时更新Gitlab的内部版本号/职位号。

在此先感谢您的帮助。

欢呼

戴夫

1 个答案:

答案 0 :(得分:1)

Nerdbank.GitVersioning没有用于GitLab CI的实现,该实现可以设置云内部版本号。 It can可以在GitLab CI中运行时识别,但是SetCloudBuildNumber方法中没有代码。如果您知道如何进行这项工作,可以共享PR吗?

相关问题