【发布时间】:2022-08-23 21:47:03
【问题描述】:
我正在开发一个 Jenkins 应用程序和管道,以测试 Apex 代码并将其从 Bitbucket 存储库部署到 Salesforce。到目前为止,我已经设法将我的存储库与我的 Jenkins 环境进行通信。我的 Jenkins 实例在我公司笔记本电脑的 Windows 10 上运行,我已完成本指南中的最后一步: https://medium.com/@r.kurchenko/setup-continuous-integration-based-on-salesforcedx-c9f461c4db03
我现在要处理的问题是,在推送到我的存储库时,尽管管道启动它甚至没有进入构建步骤并给我以下错误消息:
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
最初,我认为这可能是权限错误,因为我不是笔记本电脑的管理员,并且我的 Jenkins 实例的主目录在我的用户文件中,但是在将目录更改为其他位置后,我仍然遇到相同的错误.我认为这可能是java.nio.charset.UnmappableCharacterException: Input length = 1 异常,但是在彻底研究之后,我无法弄清楚 Jenkins 的 pull 操作在哪里执行,以及我是否有办法解决它。
对于可能导致此问题的任何线索或信息,我将不胜感激。
-
git.exe rev-list --no-walk ccf77e05e663dac6e1e32d2614ead22962da557b应该生成一个简单的单一修订号(与您从git rev-parse ccf77e05e663dac6e1e32d2614ead22962da557b^{commit}得到的结果相同,可能是ccf77e05e663dac6e1e32d2614ead22962da557b)。那应该是完全可读的。您得到的异常表明 Java 阅读器遇到了一些格式错误的 Unicode。怎么会这样,我不知道。好吧,几乎: -
这是一种可能性:Git 部分运行良好。修订版包含
Jenkinsfile。这个 Jenkinsfile 本身就是,或者以某种方式构建为格式错误的非 Unicode 文本,然后它会绊倒试图写一些文件(堆栈跟踪显示 Jenkins 正在尝试写入文件)。因此,通过在该哈希 ID 上运行git rev-parse(或git rev-list --no-walk)来检查提交中任何 Jenkinsfile 的原始字节。 -
感谢@torek 的回复。我没有将 Jenkinsfile 添加到我的存储库中,它会由管道自动创建吗?否则我很确定这不会是问题所在,除非 Jenkins 试图读取一个不存在的 Jenkinsfile。
-
我真的不知道。我不是 Jenkins 专家(我认为这个想法很好,但实现很糟糕)。但是,堆栈跟踪肯定表明 Jenkins 是写作一些东西,并因字符集异常而爆炸。
标签: java git jenkins exception bitbucket