Status: Open (View Workflow)
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.
- is related to
JENKINS-25416 text parameter with newlines causing the default goal run
JENKINS-31986 OS-related problems with Maven parameters (from job or from build step)
JENKINS-28790 Sonar database credentials in build console output not masked since LTS version 1.596.3
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
ogondza : 9eaba2af9f0fa2649390f83b9b67fe6ee22fe1ad
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.
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.
Code changed in jenkins
User: Oliver Gondža
[FIXED JENKINS-26684] Escape special chars in maven build step arguments
(cherry picked from commit 58a41bcb182290de681da01ba277b5e0d6211707)