I came here because I had the same situation described, The version of Hudson / Jenkins that I have has the same problem, it does not allow setting the working directory before calling maven.
The workaround is to configure a parameter that has the desired working directory, create a new command "mvn" that makes the change directory and then invoke the original command "mvn" of maven with all the arguments.
steps to follow:
In the project it should be noted that the project needs to be parameterized, in my case create the parameter WORKING_DIRECTORY with value $ {WORKSPACE}/maven, being "maven" the subfolder that will be the working directory.
enter image description here
Create a "custom" version of maven to modify the "mvn" command:
cp -ip /opt/apache-maven-3.5.4 /opt/maven_custom
mv /opt/maven_custom/mvn /opt/maven_custom/mvn_original
vi /opt/maven_custom/mvn:
-- content new mvn command --
cd $WORKING_DIRECTORY
/opt/maven_custom/bin/mvn_original "$@"
-- end content new mvn command --
chmod ugo+x /opt/maven_custom/mvn
Add the new maven_custom in hudson/Jenking:
Hudson Admin --> System Configurations --> Maven --> Add maven
Use the custom maven in the project
With these changes maven runs in a different working directory