4
votes

I would like to use a property, which I defined inside my pom.xml. Now I would like to refer to this property value inside my TeamCity Build Step.

At the moment I'm only able to refer the other way around to use a TeamCity property inside Maven.

In particular I want to do a SSH Deployer with a target like url/path/%maven.output.type%/something with

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

What I tried was to define a parameter in TeamCity but I have no idea how to define the value of this parameter.

Is there any way to use this property inside the TeamCity build?

1
Have you figured this out? I have the same need.CMont
Unfortunately I couldn't figure this out. I think it is just not possible at the moment.FaltFe
Meanwhile, I found a solution that I posted as an answer.CMont

1 Answers

1
votes

You can run a script that will set a teamcity parameter that you can use in a another build step. Here are the build configuration settings I use:

Create a configuration parameter with an empty text value with a name used in the next step (e.g. outputType).

Add a build step, with runner type Command line:

  • Select to run a custom script.

  • In the custom script field, enter a script that will extract the value from the pom file, and tell teamcity to set it in the parameter. For example:

    testing=sed -n 's:.*<output\.type>\(.*\)</output\.type>.*:\1:p' pom.xml

    echo "##teamcity[setParameter name='outputType' value='$testing']"

This will set the teamcity parameter outputType with the value of an element named output.type found in the current project pom file.

In another build step, you can use that parameter in a field like, for instance, the target field:

somepath/%outputType%