如何将Jenkins multiline string parameter的多行文本优雅的保存为文件

【现象】:

使用multi-line string parameter获取的文本变量,在jenkins shell里面显示为单行文本(空格分割)。

【问题】:能否转换为多行文本,并存入文件。

【解决方案】:

(假设多行文本变量名为:file_body;待写入文件的文件名变量为:file_name)

#!/usr/bin/python
import os
import io

with io.open(os.getenv("file_name"), "w", encoding="utf-8") as text_file:
    text_file.write("%s" % unicode(os.getenv("file_body")))
原文地址:https://www.cnblogs.com/imzye/p/8360234.html