Problem:
When testing Snyk projects using the Jenkins plugin, the scan may fail.
When run with -d
argument to generate debug logs, the lineCaused by: java.nio.charset.MalformedInputException: Input length = 1
is found
Discussion:
This occurs when the following situation occurs:
- Jenkins Primary system is set to accept UTF-8 characters.
- Jenkins Build Agent is set to return ANSI character set.
- When Snyk tries to return a UTF-8 character from the build agent to the primary system, it fails convert to UTF-8 and dies with the MalformedInputException.
Resolution:
Options:
- Set the environment variable JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 and restart the jenkins agent process.
- Add UTF.LANG 8 as an environment variable in the docker node that Snyk is running on