简体   繁体   中英

Jenkins java.nio.charset.UnmappableCharacterException: Input length = 1

I am working on a Jenkins application and pipeline to test and deploy Apex Code from a Bitbucket repository to Salesforce. So far I've managed to communicate my repository with my Jenkins environment. My Jenkins instance is running on Windows 10 in my company laptop, and I've reached the final steps in this guide: https://medium.com/@r.kurchenko/setup-continuous-integration-based-on-salesforcedx-c9f461c4db03

The problem I'm trying to deal with right now is that on a push to my repository, although the pipeline starts it doesn't even get to the build step and gives me the following error message:

Started by an SCM change
Started by an SCM change
Running as SYSTEM
Building in workspace C:\JenkinsHome\workspace\sfdx-ci-force-push-build
The recommended git tool is: NONE
No credentials specified
 > git.exe rev-parse --resolve-git-dir C:\JenkinsHome\workspace\sfdx-ci-force-push-build\.git # timeout=10
Fetching changes from the remote Git repository
 > git.exe config remote.origin.url {repositoryURL} # timeout=10
Fetching upstream changes from {repositoryURL}
 > git.exe --version # timeout=10
 > git --version # 'git version 2.35.1.windows.2'
 > git.exe fetch --tags --force --progress -- {repositoryURL} +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
Checking out Revision ee36df199b17d11bd7a8a020239dab1abafc5e6e (refs/remotes/origin/master)
 > git.exe config core.sparsecheckout # timeout=10
 > git.exe checkout -f ee36df199b17d11bd7a8a020239dab1abafc5e6e # timeout=10
Commit message: "Changes"
 > git.exe rev-list --no-walk ccf77e05e663dac6e1e32d2614ead22962da557b # timeout=10
FATAL: Unable to produce a script file
java.nio.charset.UnmappableCharacterException: Input length = 1
    at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:275)
    at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:306)
    at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:281)
    at java.base/sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
    at java.base/java.io.OutputStreamWriter.write(OutputStreamWriter.java:208)
    at java.base/java.io.BufferedWriter.flushBuffer(BufferedWriter.java:120)
    at java.base/java.io.BufferedWriter.close(BufferedWriter.java:268)
    at hudson.FilePath$CreateTextTempFile.invoke(FilePath.java:1660)
    at hudson.FilePath$CreateTextTempFile.invoke(FilePath.java:1630)
    at hudson.FilePath.act(FilePath.java:1200)
    at hudson.FilePath.act(FilePath.java:1183)
    at hudson.FilePath.createTextTempFile(FilePath.java:1624)
Caused: java.io.IOException: Failed to create a temp file on C:\JenkinsHome\workspace\sfdx-ci-force-push-build
    at hudson.FilePath.createTextTempFile(FilePath.java:1626)
    at hudson.tasks.CommandInterpreter.createScriptFile(CommandInterpreter.java:202)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:120)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:92)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)
    at hudson.model.Build$BuildExecution.build(Build.java:199)
    at hudson.model.Build$BuildExecution.doRun(Build.java:164)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:522)
    at hudson.model.Run.execute(Run.java:1896)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
    at hudson.model.ResourceController.execute(ResourceController.java:101)
    at hudson.model.Executor.run(Executor.java:442)
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Initially, I thought it might be a permission error, as I am not the laptop's administrator, and the home directory of my Jenkins Instance was inside my user files, but after changing the directory to somewhere else I still get the same error. I figured it might be the java.nio.charset.UnmappableCharacterException: Input length = 1 exception but, after researching it thoroughly, I cannot figure out where in Jenkins' pull operation this is executed and whether there is a way for me to solve it.

I would greatly appreciate any leads or information on what could be causing this issue.

I solved the problem by setting the language for non-Unicode programs: In Start -> Settings -> Time & Language -> Language -> Administrative language settings. Administrative tab. Screenshot here

If you run Jenkins on windows. I solved the problem by

  1. add System Environment Variable
    • KEY JAVA_TOOL_OPTIONS
    • VALUE -Dfile.encoding=UTF8
  2. restart system
  3. test build

Because on Jenkins 2.361.1 (LTS). It read jenkinsfile by using system default Encoding (Windows = x-windows-874)

Add -Dfile.encoding=UTF-8 to your jenkins.xml Example:

<arguments>-Xrs -Xss4096k -Xmx2048m -XX:MaxPermSize=512m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dfile.encoding=UTF-8</arguments>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM