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

Maven build step fail to launch mvn process when special chars are present in build variables

      Maven build step put all build variables on command line as properties. This causes problems when special characters are used. This happens often when non-trivial label expressions are used: -Dlabel_exp=w2k8&&x86.

          [JENKINS-26684] Maven build step fail to launch mvn process when special chars are present in build variables

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          core/src/main/java/hudson/tasks/Maven.java
          test/src/test/java/hudson/tasks/MavenTest.java
          http://jenkins-ci.org/commit/jenkins/66b62b9a1f9b68ef5e61304c6aff6e1bef37514e
          Log:
          Merge pull request #1567 from olivergondza/maven-special-chars-dirty

          JENKINS-26684 Escape special chars in maven build step arguments

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: core/src/main/java/hudson/tasks/Maven.java test/src/test/java/hudson/tasks/MavenTest.java http://jenkins-ci.org/commit/jenkins/66b62b9a1f9b68ef5e61304c6aff6e1bef37514e Log: Merge pull request #1567 from olivergondza/maven-special-chars-dirty JENKINS-26684 Escape special chars in maven build step arguments

          dogfood added a comment -

          Integrated in jenkins_main_trunk #3972
          JENKINS-26684 Reproduce in unittest. (Revision fae41b01c9c034ab98216c92ca6bd171b8d81d6b)
          [FIXED JENKINS-26684] Escape special chars in maven build step arguments (Revision 58a41bcb182290de681da01ba277b5e0d6211707)

          Result = SUCCESS
          ogondza : fae41b01c9c034ab98216c92ca6bd171b8d81d6b
          Files :

          • test/src/test/java/hudson/tasks/MavenTest.java

          ogondza : 58a41bcb182290de681da01ba277b5e0d6211707
          Files :

          • core/src/main/java/hudson/tasks/Maven.java

          dogfood added a comment - Integrated in jenkins_main_trunk #3972 JENKINS-26684 Reproduce in unittest. (Revision fae41b01c9c034ab98216c92ca6bd171b8d81d6b) [FIXED JENKINS-26684] Escape special chars in maven build step arguments (Revision 58a41bcb182290de681da01ba277b5e0d6211707) Result = SUCCESS ogondza : fae41b01c9c034ab98216c92ca6bd171b8d81d6b Files : test/src/test/java/hudson/tasks/MavenTest.java ogondza : 58a41bcb182290de681da01ba277b5e0d6211707 Files : core/src/main/java/hudson/tasks/Maven.java

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          test/src/test/java/hudson/tasks/MavenTest.java
          http://jenkins-ci.org/commit/jenkins/6e94ee3f5a620a2010dbbcf94eed1e834f1aa114
          Log:
          JENKINS-26684 Reproduce in unittest.

          (cherry picked from commit fae41b01c9c034ab98216c92ca6bd171b8d81d6b)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: test/src/test/java/hudson/tasks/MavenTest.java http://jenkins-ci.org/commit/jenkins/6e94ee3f5a620a2010dbbcf94eed1e834f1aa114 Log: JENKINS-26684 Reproduce in unittest. (cherry picked from commit fae41b01c9c034ab98216c92ca6bd171b8d81d6b)

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          core/src/main/java/hudson/tasks/Maven.java
          http://jenkins-ci.org/commit/jenkins/9eaba2af9f0fa2649390f83b9b67fe6ee22fe1ad
          Log:
          [FIXED JENKINS-26684] Escape special chars in maven build step arguments

          (cherry picked from commit 58a41bcb182290de681da01ba277b5e0d6211707)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: core/src/main/java/hudson/tasks/Maven.java http://jenkins-ci.org/commit/jenkins/9eaba2af9f0fa2649390f83b9b67fe6ee22fe1ad Log: [FIXED JENKINS-26684] Escape special chars in maven build step arguments (cherry picked from commit 58a41bcb182290de681da01ba277b5e0d6211707)

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          test/src/test/java/hudson/tasks/MavenTest.java
          http://jenkins-ci.org/commit/jenkins/62932bad922f94f7d273871051073d66254a1a51
          Log:
          JENKINS-26684 Reproduce in unittest.

          (cherry picked from commit fae41b01c9c034ab98216c92ca6bd171b8d81d6b)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: test/src/test/java/hudson/tasks/MavenTest.java http://jenkins-ci.org/commit/jenkins/62932bad922f94f7d273871051073d66254a1a51 Log: JENKINS-26684 Reproduce in unittest. (cherry picked from commit fae41b01c9c034ab98216c92ca6bd171b8d81d6b)

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          core/src/main/java/hudson/tasks/Maven.java
          http://jenkins-ci.org/commit/jenkins/9e30f50065b8bb213c6571f325e5e1d5008281ce
          Log:
          [FIXED JENKINS-26684] Escape special chars in maven build step arguments

          (cherry picked from commit 58a41bcb182290de681da01ba277b5e0d6211707)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: core/src/main/java/hudson/tasks/Maven.java http://jenkins-ci.org/commit/jenkins/9e30f50065b8bb213c6571f325e5e1d5008281ce Log: [FIXED JENKINS-26684] Escape special chars in maven build step arguments (cherry picked from commit 58a41bcb182290de681da01ba277b5e0d6211707)

          dogfood added a comment -

          Integrated in jenkins_main_trunk #4292
          JENKINS-26684 Reproduce in unittest. (Revision 6e94ee3f5a620a2010dbbcf94eed1e834f1aa114)
          [FIXED JENKINS-26684] Escape special chars in maven build step arguments (Revision 9eaba2af9f0fa2649390f83b9b67fe6ee22fe1ad)

          Result = UNSTABLE
          ogondza : 6e94ee3f5a620a2010dbbcf94eed1e834f1aa114
          Files :

          • test/src/test/java/hudson/tasks/MavenTest.java

          ogondza : 9eaba2af9f0fa2649390f83b9b67fe6ee22fe1ad
          Files :

          • core/src/main/java/hudson/tasks/Maven.java

          dogfood added a comment - Integrated in jenkins_main_trunk #4292 JENKINS-26684 Reproduce in unittest. (Revision 6e94ee3f5a620a2010dbbcf94eed1e834f1aa114) [FIXED JENKINS-26684] Escape special chars in maven build step arguments (Revision 9eaba2af9f0fa2649390f83b9b67fe6ee22fe1ad) Result = UNSTABLE ogondza : 6e94ee3f5a620a2010dbbcf94eed1e834f1aa114 Files : test/src/test/java/hudson/tasks/MavenTest.java ogondza : 9eaba2af9f0fa2649390f83b9b67fe6ee22fe1ad Files : core/src/main/java/hudson/tasks/Maven.java

          T Oberlies added a comment -

          This change caused a regression in the Maven build step when used with the Gerrit trigger plugin. In Jenkins 1.580.3, a Gerrit event resulted in the following command (simplified):

          [workspace] $ D:\apache-maven-3.0.5\bin\mvn.bat -f gitRepo/pom.xml -DGERRIT_HOST=git.corp "-DGERRIT_EVENT_ACCOUNT_NAME=Max Mustermann" -DGERRIT_EVENT_TYPE=ref-updated '-DGERRIT_EVENT_ACCOUNT=\"Max Mustermann\" <max.mustermann@corp>' -B -V clean deploy sonar:sonar
          

          In Jenkins 1.609.3, the following command is executed instead:

          [workspace] $ cmd.exe /C '"D:\apache-maven-3.0.5\bin\mvn.bat -f gitRepo/pom.xml -DGERRIT_HOST=git.corp "-DGERRIT_EVENT_ACCOUNT_NAME=Max Mustermann" -DGERRIT_EVENT_TYPE=ref-updated "-DGERRIT_EVENT_ACCOUNT=\""Max Mustermann\"" <max.mustermann@corp>" -B -V clean deploy sonar:sonar && exit %%ERRORLEVEL%%"'
          

          This results a build error because one of the arguments is no longer quoted correctly:

          [ERROR] Unknown lifecycle phase "Mustermann"" <max.mustermann@corp>". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
          

          T Oberlies added a comment - This change caused a regression in the Maven build step when used with the Gerrit trigger plugin. In Jenkins 1.580.3, a Gerrit event resulted in the following command (simplified): [workspace] $ D:\apache-maven-3.0.5\bin\mvn.bat -f gitRepo/pom.xml -DGERRIT_HOST=git.corp "-DGERRIT_EVENT_ACCOUNT_NAME=Max Mustermann" -DGERRIT_EVENT_TYPE=ref-updated '-DGERRIT_EVENT_ACCOUNT=\"Max Mustermann\" <max.mustermann@corp>' -B -V clean deploy sonar:sonar In Jenkins 1.609.3, the following command is executed instead: [workspace] $ cmd.exe /C '"D:\apache-maven-3.0.5\bin\mvn.bat -f gitRepo/pom.xml -DGERRIT_HOST=git.corp "-DGERRIT_EVENT_ACCOUNT_NAME=Max Mustermann" -DGERRIT_EVENT_TYPE=ref-updated "-DGERRIT_EVENT_ACCOUNT=\""Max Mustermann\"" <max.mustermann@corp>" -B -V clean deploy sonar:sonar && exit %%ERRORLEVEL%%"' This results a build error because one of the arguments is no longer quoted correctly: [ERROR] Unknown lifecycle phase "Mustermann"" <max.mustermann@corp>". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

          Not sure if this will help in your case, but I workaround this by unchecking the "Escape Quotes in Parameter Values" option in the Gerrit Trigger Advanced Options.

          Vivien Tintillier added a comment - Not sure if this will help in your case, but I workaround this by unchecking the "Escape Quotes in Parameter Values" option in the Gerrit Trigger Advanced Options.

          The regression mentionned by Tobias Oberlies seems to be broader than just the Gerrit Trigger plugin. Please see JENKINS-31986.

          As per Tobias' logs and mine, you can see the CMD execution runs with the command being both single-quoted and double-quoted:

          cmd.exe /C '"some command"'
          

          The double-quotes are clearly the issue here.

          Noël Bardelot added a comment - The regression mentionned by Tobias Oberlies seems to be broader than just the Gerrit Trigger plugin. Please see JENKINS-31986 . As per Tobias' logs and mine, you can see the CMD execution runs with the command being both single-quoted and double-quoted: cmd.exe /C ' "some command" ' The double-quotes are clearly the issue here.

            Unassigned Unassigned
            olivergondza Oliver Gondža
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: