0

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).

2 comments

Please sign in to leave a comment.