Dear all,
We get the following errors when building a maven project in Jenkins when file paths contain non-ascii characters: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: ./target/test/resources/com/itextpdf/ñoñ-ascîî
This only happens on EC2 instances we spin up automatically using the Amazon EC2 plugin (https://plugins.jenkins.io/ec2/).
Following the guidelines on https://support.cloudbees.com/hc/en-us/articles/360004397911-How-to-address-issues-with-unmappable-characters, we checked the encoding of the JVM by looking at the following system properties on the EC2 instance:
Although
these properties already seemed ok, we also tried fixing the issue by adding -Dfile.encoding=UTF-8
to the JVM Options in the Cloud configuration:

Like indicated on the cloudbees article, we also checked the Locale of the system by looking at the environment variables.
If we run a shellscript in a Jenkinsjob and execute env | grep LANG we get the following return: LANG=en_US.UTF-8
If we ssh to the machine and run env | grep LANG we get the following return: LANG=C.UTF-8
If we run the maven command directly on the machine, there are no issues with special characters.
So in other words the following command works in a ssh terminal but gives errors when run in an Execute shell section of a Freestyle Project:
/home/ubuntu/jenkins/tools/hudson.tasks.Maven_MavenInstallation/M381/bin/mvn
--file /home/ubuntu/jenkins/workspace/tmp/ñoñ-ascîî/pdfocr/pom.xml clean
We tried using Maven versions 3.6.3 and 3.8.1 and JDK versions jdk-8u221 and jdk-11.0.11 without suffice.
Does anyone have an idea what the issue might be and how we can fix this?
(We use Jenkins version
2.277.3)