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")))
Small world. Big idea!
- Welcome to visit the knowledge base of SRE and DevOps!
- License under CC BY-NC 4.0
- No personal information is collected
- Made with Material for MkDocs and generative AI tools
- Copyright issue feedback me#imzye.com, replace # with @
- Get latest SRE news and discuss on Discord Channel