'Jenkins P4 Plugin: p4sync failing to sync Unicode files
I'm having trouble with using p4sync in a Jenkins build system.
Specifically, our P4 server is unicode-enabled. This is all fine and good, and when I call p4sync in my Jenkinsfile, I make sure to specify that the server is, in fact, a utf8
(UTF-8 No BOM) server. However, when I actually sync, the sync appears to hitch when syncing files that are marked as type unicode
in the depot, causing the sync (and build) to fail with the extremely unhelpful error message ERROR: P4: Task Exception: com.perforce.p4java.exception.P4JavaException: com.perforce.p4java.exception.P4JavaException: hudson.AbortException: P4JAVA: Error(s): Unknown client error.
This issue only occurs when syncing through the Jenkins p4plugin, as well; I cannot replicate this behavior when syncing through the p4 CLI nor P4V.
I can manually go into the depot and change the filetype from unicode
to utf8
and that appears to fix the issue, but I would prefer not to have to manually resolve this issue in the depot whenever it comes up, or whenever someone happens to submit a unicode-enabled file with the wrong encoding.
Solution 1:[1]
What we ended up doing to resolve this was manually convert all files marked unicode
in the depot to utf8
, then set up a Perforce submission trigger to disallow submission of changelists containing files marked unicode
. Thus, the depot is never in a state whereby the p4sync
step fails.
Solution 2:[2]
Try running the test.Sync and test.StreamingSync tests from here: https://swarm.workshop.perforce.com/files/guest/joel_brown/p4java/JenkinsOps
See the README for instructions. set/export P4CHARSET=utf8 before.
Hopefully that gives a better/meaningful exception.
Solution 3:[3]
After updating a bunch of stuff (Perforce Server [v2015=>v2021], Jenkins [v? => v2.303.3], Jenkins P4 Plugin [v?=>v1.11.6], Java [JRE-8.?=> JDK-11.0.12]), we have the exact same problem. There seem to be some Unicode files that sync successfully, but a lot do not (the working example we found was submitted after the server update). The job is configured to use utf8 charset.
We ran the JenkinsOps test on the Jenkins workspace after the failed sync. This worked with no error IF we set the P4CHARSET environment variable to utf8. This did not work when we did not set the variable, or set it to winansi and we get a complex error message containing the “Unknown client error” string. P4 and P4V have basically the same behavior. P4/P4V in winansi mode returns the error message “Translation of file content failed near line 1 file C:\workspace\SomeExample.txt”. Again, everything works fine with JenkinsOps and p4/p4v if the utf8 mode is active. All in all it looks to me like the Jenkins job does not apply the utf8 charset, although it is set in the job parameters.
Solution 4:[4]
A workaround is to
set P4CHARSET=utf8
before starting up the Jenkins process.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Casey Benson |
Solution 2 | J Brown |
Solution 3 | Nimantha |
Solution 4 | Chad Vernon |