Store multiline string parameter into file in Jenkins
Problem
When using multi-line string parameter
to get text variable in Jenkins, the result may appear in one line as a shell variable with space seperation.
Explaination
You should convert to multiline text first by specifying seperator and save into a file.
Solution
assuming multiline variable in Jenkins is file_body
, and written file name is file_name
, possible convert script could be:
#!/usr/bin/env 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")))