简体   繁体   English

如何使用Maven在TFS中获取$ {buildNumber}?

[英]How to get ${buildNumber} in TFS with Maven?

I need to add the buildNumber in my generated manifest file with Maven. 我需要使用Maven在生成的清单文件中添加buildNumber。 We use TFS (Team Foundation Server) as our repository. 我们使用TFS (Team Foundation Server)作为存储库。 Is there any way to access it? 有什么办法可以访问它吗?

Below link explain the how get build number with Git, SVN or Mercuria. 下面的链接说明了如何使用Git,SVN或Mercuria获取内部版本号。

http://www.yegor256.com/2014/07/03/how-to-read-manifest-mf.html http://www.yegor256.com/2014/07/03/how-to-read-manifest-mf.html

I also need the same thing with TFS? 我也需要TFS上的东西吗?

You can use ${env.TF_BUILD_BUILDNUMBER} environment variable to get TFS build number. 您可以使用$ {env.TF_BUILD_BUILDNUMBER}环境变量来获取TFS内部版本号。

Please have a check on this link: https://blogs.blackmarble.co.uk/blogs/rfennell/post/2014/12/16/Setting-a-build-version-in-a-JAR-file-from-TFS-build.aspx 请检查此链接: https : //blogs.blackmarble.co.uk/blogs/rfennell/post/2014/12/16/Setting-a-build-version-in-a-JAR-file-from- TFS-build.aspx

I think the correct variable number is env.TFS_CHANGESET or just TFS_CHANGESET. 我认为正确的变量号是env.TFS_CHANGESET或只是TFS_CHANGESET。 It worked for me. 它为我工作。

Predefined variables in TFS: TFS中的预定义变量:

  • Build.SourceVersion - Git: The commit ID. Build.SourceVersion -Git:提交ID。

  • BUILD_SOURCEVERSION - TFVC: the changeset. BUILD_SOURCEVERSION -TFVC:更改集。

A list of all variables here: https://www.visualstudio.com/en-us/docs/build/define/variables 此处所有变量的列表: https : //www.visualstudio.com/zh-cn/docs/build/define/variables

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM