0
votes

The configuration passes a property to Maven using the "Additional Maven command line parameters" setting for the Maven runner. This is done with -Darguments='' so the maven-release-plugin can use the arguments on each run as it forks new processes.

For one property the configuration is:

-DsomeProp=%teamcity.agent.name% -Darguments='-DimportantProp=true'

The problem is when passing multiple properties like so:

-DsomeProp=%teamcity.agent.name% -Darguments='-DimportantProp=true -DsecondProp=file_on_disk.name'

For the multiple properties configuration the Build log shows that importantProp gets resolved as true -Dsecondprop=file_on_disk.name which is expectedly an invalid value. The second property secondProp is then not applied as the string gets absorbed into the value of importantProp.

The reason to do this is to simplify test runs on TeamCity and not to change the poms for each test. I see hardly any examples for this configuration on TeamCity.

2

2 Answers

1
votes

your props differ by -DsecondProp=true. So, you should create only one prop for a pass to build. Let's name mainProp

Also, we need to add new prop which contains empty if not checked or -DsecondProp=true if checked. Create checkbox parameter additionalParam with

  • checked value - -DsecondProp=true
  • unchecked value - `` (nothing)

Now we need to add this cb parameter our mainProp. mainProp = -DsomeProp=%teamcity.agent.name% -Darguments='-DimportantProp=true %additionalParam%'

When you will triggered the build you can check the checkbox and pass -DsomeProp=%teamcity.agent.name% -Darguments='-DimportantProp=true -DsecondProp=true

1
votes

Applying a configuration parameter to the configuration twice has worked. Thanks for the configuration parmeter suggestion Senior Pomidor.

Create configuration parameter in build parameters or build template %mavenArguments%:

-DpropCheck=true -DpropPath=file_on_disk-1.path

Then apply the supplied configuration parameter in the Additional Maven command line parameters on the Maven build step (works directly on the build step or through build template) like this:

%mavenArguments%
-Darguments='%mavenArguments%'

I still have no idea why it's not applied correctly by writing directly into the Additional Maven command line parameters but it finally works.