Force logs encoding

This commit is contained in:
Charles Care
2019-12-05 15:42:41 +00:00
parent cdd22ebbac
commit c3ac2053b5
2 changed files with 12 additions and 3 deletions

View File

@@ -32,7 +32,7 @@ module Pipeline::Build
image: image_name, image: image_name,
image_tag: image_tag, image_tag: image_tag,
git_tag: build_tag, git_tag: build_tag,
logs: img.logs.inspect.force_encoding("ISO-8859-1").encode("UTF-8") logs: img.logs.inspect
} }
end end

View File

@@ -56,13 +56,22 @@ module Pipeline::Util
{ {
cmd: cmd_string, cmd: cmd_string,
success: success?, success: success?,
stdout: stdout, stdout: fix_encoding(stdout),
stderr: stderr stderr: fix_encoding(stderr)
} }
end end
private private
def fix_encoding(text)
return nil if text.nil
text.force_encoding("ISO-8859-1").encode("UTF-8")
rescue => e
puts e.message
puts e.backtrace
"--- failed to encode as UTF-8: #{e.message} ---"
end
def invoke_process def invoke_process
c = cmd c = cmd
captured_stdout = [] captured_stdout = []