This Question is Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
2 Replies Last post: Feb 11, 2013 2:02 PM by Lubos Kovarik  
Lubos Kovarik Newbie 2 posts since
Feb 6, 2013
Currently Being Moderated

Feb 6, 2013 6:13 PM

Passing XML as a build parameter

Hi guys.

 

I'm trying to make a dynamicly confugired TestNG suite like this:

 

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Custom suite" parallel="false">
    <test verbose="1" name="BATHS PUMA Custom xml" annotations="JDK">
        ${testng.custom.xml}
    </test>
</suite>

 

Then, I want to pass there some XML block from TeamCity build parameter, so in Maven build step I have this additional Maven parameter (and few others):

-Dtestng.custom.xml=%TESTNG_CUSTOM_XML%

 

I let user fill this each time in the promt window when executing the run configuration.

But I'm getting some errors on every different try I made. Problems are with spaces and quotes.

 

An example of what I need to pass:

<classes><class name="mypackage.Class1"/></classes>

 

An error I get in the build log:

Unknown lifecycle phase "name=mypackage.Class1/></classes>". You must specify a valid lifecycle phase or a goal in the format...

 

Detail from build log when passing it to Maven:

-Dtestng.custom.xml=<classes><class name="mypackage.Class1"/></classes>

So now there is a problem that there is a space after <class

 

 

The solution would be to have it all in the quotes and escape the existing quotes, right? So, I want to achieve this:

-Dtestng.custom.xml="<classes><class name=\"mypackage.Class1\"/></classes>"

 

But when I pass this as a build parameter...

"<classes><class name=\"mypackage.Class1\"/></classes>"

 

...in the build log it sudenly looks like this and it fails on the same error:

"-Dtestng.custom.xml="<classes><class name=\"mypackage.Class1\"/></classes>""

So there was somehow added the quotes around all this.

 

I tried several other things, but nothing worked for me. Do you have any other idea how to write this so it would work? Thanks.

It may have something to do with this: http://youtrack.jetbrains.com/issue/TW-22100

 

We are running TeamCity Enterprise 7.1.3 (build 24266).

Pavel Sher JetBrains 2,361 posts since
Mar 6, 2008
Currently Being Moderated
Feb 6, 2013 11:29 PM in response to: Lubos Kovarik
Re: Passing XML as a build parameter

You can try to add Ant build step before Maven with build.xml defined right in the TeamCity like this:

<project name="produce_dynamic_testng_xml" default="testng.xml">

 

<target name="testng.xml">

 

<echo file="testng-custom.xml><![CDATA[

 

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Custom suite" parallel="false">
    <test verbose="1" name="BATHS PUMA Custom xml" annotations="JDK">
        %testng.custom.xml%
    </test>
</suite>

]]></echo>

</target>

 

</project>

 

Although in my opinion it'd be more user friendly to ask developers for a list of class names, without any markup. Then in the first step you could convert this list to testng.xml with help of some script and then Maven step could start.

More Like This

  • Retrieving data ...