Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-23831

Multiline (all) job parameters passed to "Invoke top-level Maven targets" step

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • maven-plugin
    • Jenkins 1.532.1
      Maven plugin 2.0.2

      Reproduction
      1. I created a sample freestyle job (it doesn't do anything and makes no sense, event the pom is not there) and added "Invoke top-level Maven targets" step.
      2. I selected "This build is parametrized" and added many types of parameters (both default and coming from other plugins):

      • text parameter
      • boolean value
      • build selector for copy artifact
      • password parameter
      • string parameter

      3. When the project is run, all parameters are added as "-Dkey=value" to Maven invocation:

      [workspace] $ C:\Software\apache-maven-3.1.1\bin\mvn.bat -f pom.xml "-Dtext=abcd
      efgh" '-Dcopyartifactselector=<StatusBuildSelector plugin="copyartifact@1.28"> <stable>true</stable></StatusBuildSelector>' "-Dstring=string asdasd" -Dbool=true ******** clean
      FATAL: command execution failed
      java.io.IOException: Cannot run program "C:\Software\apache-maven-3.1.1\bin\mvn.bat" (in directory "G:\JenkinsData\JenkinsHome\jobs\test-one\workspace"): Argument has embedded quote, use the explicit CMD.EXE call.
      at java.lang.ProcessBuilder.start(Unknown Source)
      at hudson.Proc$LocalProc.<init>(Proc.java:244)
      at hudson.Proc$LocalProc.<init>(Proc.java:216)
      at hudson.Launcher$LocalLauncher.launch(Launcher.java:773)
      at hudson.Launcher$ProcStarter.start(Launcher.java:353)
      at hudson.Launcher$ProcStarter.join(Launcher.java:360)
      at hudson.tasks.Maven.perform(Maven.java:329)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:781)
      at hudson.model.Build$BuildExecution.build(Build.java:199)
      at hudson.model.Build$BuildExecution.doRun(Build.java:160)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:562)
      at hudson.model.Run.execute(Run.java:1665)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:246)
      Caused by: java.lang.IllegalArgumentException: Argument has embedded quote, use the explicit CMD.EXE call.
      at java.lang.ProcessImpl.isQuoted(Unknown Source)
      at java.lang.ProcessImpl.needsEscaping(Unknown Source)
      at java.lang.ProcessImpl.createCommandLine(Unknown Source)
      at java.lang.ProcessImpl.<init>(Unknown Source)
      at java.lang.ProcessImpl.start(Unknown Source)
      ... 16 more

      Why are parameters implicitly included in the call? Is there a way to disable this behaviour?
      I would expect the step to require explicit parameters provisioning through Properties field in the config.

          [JENKINS-23831] Multiline (all) job parameters passed to "Invoke top-level Maven targets" step

          I have the same behavior in Jenkins 1.554.3 and Maven Project Plugin 2.3

          Alexis Morelle added a comment - I have the same behavior in Jenkins 1.554.3 and Maven Project Plugin 2.3

          Rasmus Voss added a comment -

          This is a problem as the handling is different in windows and unix.
          I have a build i can only run in unix because of the following error.

          mvn.bat" (in directory JOBNAME"): Argument has embedded quote, use the explicit CMD.EXE call.

          Works perfectly find in unix.

          Rasmus Voss added a comment - This is a problem as the handling is different in windows and unix. I have a build i can only run in unix because of the following error. mvn.bat" (in directory JOBNAME"): Argument has embedded quote, use the explicit CMD.EXE call. Works perfectly find in unix.

          dmeibusch added a comment -

          I too am annoyed at this behaviour by the Invoke top level Maven Targets.

          Our current workaround is to use the EnvInject to change the offending parameters as a build step just before invoking the Maven build.

          For the OP's example, the EnvInject would specify properties:

          copyartifactselector=empty
          

          dmeibusch added a comment - I too am annoyed at this behaviour by the Invoke top level Maven Targets. Our current workaround is to use the EnvInject to change the offending parameters as a build step just before invoking the Maven build. For the OP's example, the EnvInject would specify properties: copyartifactselector=empty

          Brantone added a comment -

          Is there even any reasoning on : why it does it this way??

          Brantone added a comment - Is there even any reasoning on : why it does it this way??

          I too have this issue with Jenkins 1.625.2 (LTS as I write).

          There is absolutly no reason in automatically passing the arguments to the Maven command line as they are available through the $parameter notation. This behaviour only causes trouble! This issue is especially blocking when the argument has spaces and or special characters in it, as the behaviour then depends on how the parsing is done, which is (as per JENKINS-23831) quite OS-related.

          There could at least be a checkbox: "do not pass job parameters automatically as Maven parameters", to maintain retro-compatibility for people already using the feature (which is a bad idea, but hey...), while allowing us to disable the behaviour.

          Noël Bardelot added a comment - I too have this issue with Jenkins 1.625.2 (LTS as I write). There is absolutly no reason in automatically passing the arguments to the Maven command line as they are available through the $parameter notation. This behaviour only causes trouble! This issue is especially blocking when the argument has spaces and or special characters in it, as the behaviour then depends on how the parsing is done, which is (as per JENKINS-23831 ) quite OS-related. There could at least be a checkbox: "do not pass job parameters automatically as Maven parameters", to maintain retro-compatibility for people already using the feature (which is a bad idea, but hey...), while allowing us to disable the behaviour.

            Unassigned Unassigned
            tptak Tomasz Ptak
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: