gpt4 book ai didi

maven - 在 TeamCity 构建步骤中使用 Maven 属性

转载 作者:行者123 更新时间:2023-12-02 03:12:08 28 4
gpt4 key购买 nike

我想使用我在 pom.xml 中定义的属性。现在我想在我的 TeamCity Build Step 中引用这个属性值。

目前,我只能通过另一种方式在 Maven 中使用 TeamCity 属性。

特别是我想做一个 SSH 部署器,目标是 url/path/%maven.output.type%/something with

<properties>
<!-- Art der Entwicklung -->
<output.type>testing</output.type>
</properties>

我尝试的是在 TeamCity 中定义一个参数,但我不知道如何定义此参数的值。

有没有办法在 TeamCity 构建中使用此属性?

最佳答案

您可以运行一个脚本来设置一个 teamcity 参数,您可以在另一个构建步骤中使用该参数。以下是我使用的构建配置设置:

创建一个带有空文本值的配置参数,其名称在下一步中使用(例如 outputType)。

添加一个构建步骤,使用 runner 类型命令行:

  • 选择运行自定义脚本。
  • 在自定义脚本字段中,输入将从 pom 文件中提取值的脚本,并告诉 teamcity 在参数中设置它。例如:

    测试= sed -n 's:.*<output\.type>\(.*\)</output\.type>.*:\1:p' pom.xml
    echo "##teamcity[setParameter name='outputType' value='$testing']"

  • 这将使用在当前项目 pom 文件中找到的名为 output.type 的元素的值设置 teamcity 参数 outputType。

    在另一个构建步骤中,您可以在一个字段中使用该参数,例如,目标字段:
    somepath/%outputType%

    关于maven - 在 TeamCity 构建步骤中使用 Maven 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39392568/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com