Pipeline step to append to a file...

12 views
Skip to first unread message

Michael Carter

unread,
May 19, 2021, 11:42:51 PM5/19/21
to Jenkins Developers
I have a situation where I'm piecing together a large file.  Is there some pipeline command for appending to a file?   Trying to keep it in memory is problematic.

Björn Pedersen

unread,
May 20, 2021, 1:14:13 AM5/20/21
to Jenkins Developers
Hi,

just don't use the pipeline groovy code for that , use suitable external tools (e.g. cat and shell pipes)

sh ``` cat part1 > file; cat part2 >> file ```


[1] has a recommendation:
In general try to fit the tool to the job. Consider writing short Shell/Batch/Groovy/Python scripts when running a complex process using a build agent. Good examples include processing data, communicating interactively with REST APIs, and parsing/templating larger XML or JSON files. The sh and bat steps are helpful to invoke these, especially with returnStdout: true to return the output from this script and save it as a variable (Scripted Pipeline).

The Pipeline DSL is not designed for arbitrary networking and computation tasks - it is intended for CI/CD scripting.

Björn
Reply all
Reply to author
Forward
0 new messages