0

I have a build in TeamCity that runs bash using exec-maven-plugin and it runs a script and should take 4 arguments, 2 of them I provide from pom and 2 should come from TeamCity environment.

I am using following command line parameters in TeamCity build:

-DpreparationGoals=verify -Darguments='-Dfoo=1 -Dbar=2'

And following POM:

            <execution>
                <id>Native</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>exec</goal>
                </goals>
                <configuration>
                    <executable>bash</executable>
                    <arguments>
                        <argument>scripts/run_script.sh</argument>
                        <argument>${version}</argument>
                        <argument>${version.Native}</argument>
                        <argument>${foo}</argument>
                        <argument>${bar}</argument>
                    </arguments>
                </configuration>
            </execution>

It manages to resolve first argument but it passes the whole rest of arguments string as first argument and second is left unresolved:

[DEBUG] Executing command line: [bash, scripts/run_script.sh, 1.2, 2.4, 1 -Dbar=2]

I tried to replace single quotes in Maven command line parameters with double it didn't work, was complaining about unbalanced quotes.

Viktor Stolbin
  • 2,899
  • 4
  • 32
  • 53
  • 2
    Speaking as someone who knows bash but not TeamCity, `-Darguments='arg1 arg2 arg3'` is a **really** unfortunate design decision. How is TeamCity supposed to know where one argument ends and the next begins without implementing a full shell parser with quoting/escaping support? Do you have documentation you can link to so those of us who know bash but not TeamCity can inform ourselves as to how the other side of this is supposed to work? – Charles Duffy Aug 21 '18 at 20:34
  • 1
    Heh. At least upstream knows it's a problem: https://youtrack.jetbrains.com/issue/TW-7964 -- flagged critical since 2009 and still open. If only they'd brought in someone from a UNIX background (and accustomed to thinking of argument vectors as *arrays* of strings, rather than as individual strings) at design time, vs. coding themselves into a corner way back when. – Charles Duffy Aug 21 '18 at 20:38

0 Answers0