Store multiline string parameter into file in Jenkins
现象
使用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")))
Disclaimer
- License under
CC BY-NC 4.0
- Copyright issue feedback
me#imzye.me
, replace # with @ - Not all the commands and scripts are tested in production environment, use at your own risk
- No privacy information is collected here