Problem with custom command (maven) with quoted parameters

1,059 views
Skip to first unread message

Med

unread,
Aug 2, 2015, 4:11:20 PM8/2/15
to go-cd
Hi all,

I'm setting up a test pipeline using GO. My Custom command configuration looks like:

<exec command="mvn" workingdir="alien4cloud" >
<arg>install</arg>
<arg>-P UITest</arg>
<arg>-e</arg>
<arg>-Dui-task="ittest-admin --browser=chrome"</arg>
</exec>.

Looks like when the custom command is run the last quote in parameter got lost and it fails with the following error message:
18:51:11.202 [ERROR] Failed to execute goal fr.fastconnect:calm-yeoman-maven-plugin:1.0.3:test ("ittest-admin --browser=chrome) on project alien4cloud-ui: Execution "ittest-admin --browser=chrome of goal fr.fastconnect:calm-yeoman-maven-plugin:1.0.3:test failed: Unbalanced quotes in grunt "ittest-admin --browser=chrome -> [Help 1]
18:51:11.211 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal fr.fastconnect:calm-yeoman-maven-plugin:1.0.3:test ("ittest-admin --browser=chrome) on project alien4cloud-ui: Execution "ittest-admin --browser=chrome of goal fr.fastconnect:calm-yeoman-maven-plugin:1.0.3:test failed: Unbalanced quotes in grunt "ittest-admin --browser=chrome
18:51:11.211 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
18:51:11.211 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
18:51:11.211 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
18:51:11.212 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
18:51:11.212 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
18:51:11.212 	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
18:51:11.212 	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
18:51:11.214 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
18:51:11.214 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
18:51:11.214 	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
18:51:11.214 	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
18:51:11.214 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
18:51:11.215 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:51:11.215 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
18:51:11.215 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:51:11.215 	at java.lang.reflect.Method.invoke(Method.java:606)
18:51:11.215 	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
18:51:11.215 	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
18:51:11.215 	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
18:51:11.215 	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
18:51:11.216 Caused by: org.apache.maven.plugin.PluginExecutionException: Execution "ittest-admin --browser=chrome of goal fr.fastconnect:calm-yeoman-maven-plugin:1.0.3:test failed: Unbalanced quotes in grunt "ittest-admin --browser=chrome
18:51:11.216 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
18:51:11.216 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
18:51:11.216 	... 19 more
18:51:11.216 Caused by: java.lang.IllegalArgumentException: Unbalanced quotes in grunt "ittest-admin --browser=chrome
18:51:11.216 	at org.apache.commons.exec.CommandLine.translateCommandline(CommandLine.java:391)
18:51:11.216 	at org.apache.commons.exec.CommandLine.parse(CommandLine.java:82)
18:51:11.216 	at org.apache.commons.exec.CommandLine.parse(CommandLine.java:64)
18:51:11.217 	at fr.fastconnect.ExecuteCommandUtil.executeCommand(ExecuteCommandUtil.java:32)
18:51:11.217 	at fr.fastconnect.YeomanTestMojo.execute(YeomanTestMojo.java:28)
18:51:11.217 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
18:51:11.217 	... 20 more
18:51:11.217 [ERROR] 
18:51:11.217 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
18:51:11.217 [ERROR] 
18:51:11.217 [ERROR] For more information about the errors and possible solutions, please read the following articles:
18:51:11.218 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
18:51:11.218 [ERROR] 
18:51:11.218 [ERROR] After correcting the problems, you can resume the build with the command
18:51:11.218 [ERROR]   mvn <goals> -rf :alien4cloud-ui
18:51:11.659 [go] Current job status: failed.

Any suggestions on how to solve this issue ? Thanks

Aravind SV

unread,
Aug 2, 2015, 11:48:50 PM8/2/15
to go...@googlegroups.com
I like to think of the custom command as a command with every argument separated by single-quotes. So, your current task is:

<exec command="mvn" workingdir="alien4cloud" >
  <arg>install</arg>
  <arg>-P UITest</arg>
  <arg>-e</arg>
  <arg>-Dui-task="ittest-admin --browser=chrome"</arg>
</exec>

That equates to (on the shell):
mvn 'install'  '-P UITest'  '-e'  '-Dui-task="ittest-admin --browser=chrome"'

or, when simplified:
mvn install '-P UITest' -e '-Dui-task="ittest-admin --browser=chrome"'


My guess is that if you run what I showed above (including the single-quotes) in a shell, you'll get the error you came up with. You probably need something like the one below:

<exec command="mvn" workingdir="alien4cloud" >
  <arg>install</arg>
  <arg>-P</arg>
  <arg>UITest</arg>
  <arg>-e</arg>
  <arg>-Dui-task=ittest-admin --browser=chrome</arg>
</exec>

That is equivalent to:
mvn install -P UITest -e '-Dui-task=ittest-admin --browser=chrome'


I feel that is closer to your intention. If that doesn't work, you might want to try using /bin/bash -c or use a shell script instead - and call it from within Go.

Cheers,
Aravind


--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Med

unread,
Aug 3, 2015, 4:52:27 AM8/3/15
to go-cd
Thank you! That solved the problem.

Cheers,
Reply all
Reply to author
Forward
0 new messages