近日,突然发现任务集群的jenkins异常退出了,没有任何的迹象。后来排查到jenkins的job的日志后,找到了以下错误日志。
Started by user unknown or anonymous
Running as SYSTEM
Building in workspace /Users/xxxxx/work/jenkins2/jenkins_home/workspace/xxxx_1731652075874
FATAL: Unable to produce a script file
Also: 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:307)
at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
at java.base/sun.nio.cs.StreamEncoder.write(StreamEncoder.java:132)
at java.base/java.io.OutputStreamWriter.write(OutputStreamWriter.java:205)
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:1650)
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:307)
at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
at java.base/sun.nio.cs.StreamEncoder.write(StreamEncoder.java:132)
at java.base/java.io.OutputStreamWriter.write(OutputStreamWriter.java:205)
at java.base/java.io.BufferedWriter.flushBuffer(BufferedWriter.java:120)
at java.base/java.io.BufferedWriter.write(BufferedWriter.java:233)
at java.base/java.io.Writer.write(Writer.java:249)
at hudson.FilePath$CreateTextTempFile.invoke(FilePath.java:1651)
at hudson.FilePath$CreateTextTempFile.invoke(FilePath.java:1622)
at hudson.FilePath.act(FilePath.java:1192)
at hudson.FilePath.act(FilePath.java:1175)
at hudson.FilePath.createTextTempFile(FilePath.java:1616)
Caused: java.io.IOException: Failed to create a temp file
经过一番查找后,才发现是jenkins的一个bug引起,且可以通过增加Java Opts的一个文件编码的命令行参数解决:
-Dfile.encoding=UTF8
如
nohup java $SERVICE_OPTS -Dfile.encoding=UTF8 -jar $HOME/work/jenkins2/jenkins.war --httpPort=8080 > jenkins.log 2>&1 &