在tfs上进行Java构建,如何在UI上使用TFS将构建版本注入pom.xml?

I have a TFS build definition that deals with a java spring backend application that is built with Maven. I have a build step called "Maven pom.xml" where I obviously can set some options of the pom.xml.

I need to change the "version" tag in the pom.xml using TFS whilst building, so that the "info" endpoint in actuator serves the correct version number including the TFS build number.

1) Is this possible using the TFS UI at all?

GvNDu.png

2) If yes, should I change "Options" textbox content or "MAVEN_OPTS" and how do I feed parameters there, that change in the pom.xml?

解决方案

Yes, it is possible. Follow these steps:

1) Create another maven build step before the maven build task with "package" goal.

2) Set "Goal(s)" to:

versions:set -DnewVersion=[VersionInformation] -DskipTests

[VersionInformation] can be any string denoting your desired version. You can use TFS variables here. An example for this string might be: 2.3.5.$(Build.BuildNumber)-RELEASE so your Goal for the versions:set maven build task would look like:

versions:set -DnewVersion=2.3.5.$(Build.BuildNumber)-RELEASE -DskipTests

Save your changes. This way, the build-info.properties file under /target/classes/META-INF folder will include your version number that will be served via the "info" actuator.

3) If you need to copy your build output to another place, make sure that you copy the META-INF folder as well. If your current copy step doesn't copy that folder to your ultimate drop place;

a. Create a "Copy files" build step after build step(s).

b. Write "$(build.sourcesdirectory)/target/classes/META-INF" into the "Source Folder" textbox.

c. Write * into the Contents textbox. That will copy all files in META-INF just in case.

d. Append "/classes/META-INF" to your normal drop place in the Target Folder textbox so that META-INF files are copied to the right place.

e. Save your changes.

This way, your build definition correctly sets the version information and copies the necessary files to your drop location. To access your version info, use your "info" actuator endpoint.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值