Details
-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
8.1.8
-
None
-
1
-
Severity 2 - Major
-
1
-
Description
Issue Summary
This is reproducible on Data Center:
Bamboo fails to load default encoded files when loaded from an "Inject variable task" on Windows. This is not reproducible on Linux hosts/agents.
The default character encoding on Windows is UTF-16. UTF-16 encoded files result in a corrupted variable import. When forcing the file encoding as UTF-8 the variable is partially recognised and allows a workaround to be used.
Steps to Reproduce
It is assumed that Windows running the Bamboo Agent uses the default input/output encoding.
- Create a Script task
- Use the below script contents
echo poWindowCloneDir=D:\bamboo-home\xml-data\build-dir\TP-TBP-JOB1 > a.txt type a.txt Get-Content a.txt
- Inject the a.txt file using an "Inject Variable task"
- Monitor the build logs for "Injected variable bamboo..."
Expected Results
Bamboo should understand the file encoding and load it correctly. The variables should be parsed from the created file without further hacks (check workaround)
Injected variable bamboo.inject.poWindowCloneDir=D:\bamboo-home\xml-data\build-dir\TP-TBP-JOB1
Actual Results
We can observe in the build logs that a broken/corrupted variable is created with unrecognised content:
simple 27-Sep-2022 00:36:19 Starting task 'Inject Bamboo variables' of type 'com.atlassian.bamboo.plugins.bamboo-variable-inject-plugin:inject' simple 27-Sep-2022 00:36:19 Injected variable bamboo.inject.�= in LOCAL scope simple 27-Sep-2022 00:36:19 Injected variable bamboo.inject.??p�o�W�i�n�d�o�w�C�l�o�n�e�D�i�r�=�"�D�:��b�a�m�b�o�o�-�h�o�m�e��x�m�l�-�d�a�t�a��b�u�i�l�d�-�d�i�r��T�P�-�T�B�P�-�J�O�B�1�"� in LOCAL scope
When using a file encoded with UTF-8, the "\" (backslash) character is missing from the variable value:
simple 27-Sep-2022 02:12:48 Starting task 'Inject Bamboo variables' of type 'com.atlassian.bamboo.plugins.bamboo-variable-inject-plugin:inject' simple 27-Sep-2022 02:12:48 Injected variable bamboo.inject.poWindowCloneDir=D:bamboo-homexml-databuild-dirTP-TBP-JOB1 in LOCAL scope
Workaround
- Set the Script task interpreter as PowerShell
- Force the script to create UTF-8 encoded files. Add the $PSDefaultParameterValues variable at the beginning of the Script task:
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
- Modify the command and add double backslashes to the variable contents. This way Bamboo will recognise them as legitimate characters. This is the final script:
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' echo poWindowCloneDir=D:\\bamboo-home\\xml-data\\build-dir\\TP-TBP-JOB1 > a.txt type a.txt Get-Content a.txt
The workaround will generate a file that is recognised by Bamboo and can be correctly imported as a variable. This has been tested with the "\" (backslash) character. It may also manifest in other character sets.
simple 27-Sep-2022 14:39:05 Starting task 'Inject Bamboo variables' of type 'com.atlassian.bamboo.plugins.bamboo-variable-inject-plugin:inject' simple 27-Sep-2022 14:39:05 Injected variable bamboo.inject.poWindowCloneDir=D:\bamboo-home\xml-data\build-dir\TP-TBP-JOB1 in LOCAL scope
Attachments
Issue Links
- mentioned in
-
Page Loading...