How to change the wrong encoding in Bamboo that is causing crashes or characters to display incorrectly
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
- You are trying to create a Jira issue from Bamboo and it crashed
- Code changes with special characters such as umlauts are replaced with different characters
- Angled brackets in the UI are replaced with different characters
- The build logs are getting cluttered with different characters
- Errors regarding Illegal characters. For example:
error 19-Jul-2022 10:12:34 java.nio.file.InvalidPathException: Illegal char <?> at index 41: Sample ? filename.txt
Cause
The system character encoding is wrong with the expected being UTF8
.
Solution
The solution below forces the codepage used by the Bamboo Agent Java application while transmitting the logs back to the Bamboo server. You may still experience garbled text on your build outputs while logging non-English characters in languages such as Portuguese, Spanish, Polish, German, Hebrew, Japanese, Korean, Chinese, etc. In case you still see issues after applying the instructions below, make sure to add the chcp 65001
command before invoking your program within the same Script Task on your Bamboo Plan.
The Windows' chcp
command either displays or changes the active code page used to display character glyphs in a console window. Codepage 65001 is the equivalent of UTF-8, which works on most of the cases. You may also try other codepages that would match your environment closely.
Shutdown Bamboo
Edit
$BAMBOO_INSTALL/bin/setenv.sh
(.bat for Windows or follow this article if you are starting as a service)Add this line in quotes under
JVM_SUPPORT_RECOMMENDED_ARGS=
-Dfile.encoding=utf-8 -Dsun.jnu.encoding=UTF-8
- Restart Bamboo and check that your system encoding changes to UTF-8 from the System information page.
If the issue is manifesting on your remote agents, e.g. the the build logs are replacing UTF-8 characters with question marks or there are errors about illegal characters in your builds that occur on a remote agent:
- Shutdown the remote agent
- Edit
$BAMBOO_AGENT_HOME/
conf/wrapper.conf
Add the below lines:
wrapper.java.additional.#=-Dfile.encoding=UTF-8 wrapper.java.additional.#=-Dsun.jnu.encoding=UTF-8
Please replace the # with the next available digit in the series of Java additionals. The numbers must be sequential for the argument to apply.- Restart the agent and check that your system encoding changes to UTF-8 from the general configuration page.