Extra quote in Rake TESTOPTS build step

I've successfully been using a Rake build step in my configuration which passes a TESTOPTS option in the "Additional Rake command line" field:


However, I now want to add a second option to the Rake TESTOPTS field. When I run rake manually, at the command line, I use the following syntax, using double quotes to encapsulate both options:

rake <task> TESTOPTS="-v --name=<...>"

This works fine at the command line.

But, when I use this same syntax in my TeamCity build step, the step fails. Looking at the build log I see TeamCity seems to add an extra quote before the TESTOPTS keyword - which presumably causes rake to fail:

Starting: C:\Ruby\bin/ruby.exe  C:\TeamCity\buildAgent\plugins\rake-runner\lib\rb\runner\rakerunner.rb  --rakefile C:\TeamCity\buildAgent\work\ae1edd57fba32e1c\QA\Rakefile  "TESTOPTS="-v --name=/test(?!.*_n$)/"

Why is this extra quote being added? I've tried several combinations of quotes to 'counter' TeamCity, but i've consistently failed.

Any suggestions is appreciated


Comment actions Permalink

Hi Michael,

What version of TeamCity do you use?

You may try to use

TESTOPTS=\"-v --name=/test(?!.*_n$)/\"

Comment actions Permalink

Hello, Michael,

When using java process running API it's not always possible to control the actuall program parameters values that are passed to an executable.
For examaple, Java treats key=" the value" parameter as unquoted (due to staring quote miss) and quotes it once more.

Did you try specifying this parameter as "TESTOPTS=-v --name=/test(?!.*_n$)/" (put whole value in double quotes)?

Comment actions Permalink

Thanks Victory and Vladislav for your responses

Here are the results from your suggestions:

Build Parameter
Build Log Result
TESTOPTS="-v --name=/test(<...>)/" "TESTOPTS="-v --name=/test(<...>)/" Extra quote added in front of TESTOPTS - Fail
TESTOPTS=\"-v --name=/test(<...>)/\" TESTOPTS=\"-v --name=/test(<...>)/\ Tail quote removed - Fail
"TESTOPTS=-v --name=/test(<...>)/" "TESTOPTS=-v --name=/test(<...>)/" No change to build parameter, and Rake ran correctly - Worked

So - it looks like putting quotes around the whole phrase worked - thank you.

I am still curious why TeamCity would manipulate the quoting around the build parameters, though. It seems this is unexpected behavior.
I am running TeamCity version 6.5.3

thanks again,

Comment actions Permalink


Glad to hear that the workaround helped you in this case.
Arguments quoting is a knows issue in TeamCity (concerns not only Rake runner) covered by http://youtrack.jetbrains.net/issue/TW-7964. Please vote for it and watch progress.


Please sign in to leave a comment.