Resolved: How to append to a file in Jenkins pipeline? 0 By Isaac Tonny on 17/06/2022 Issue Share Facebook Twitter LinkedIn Question: I have the following simple pipeline where I just want to append multiple lines into a file node("jenkins-builder") { stage("test") { String s = "JIRA-1234 | Use "'" in place of apostrophes in patient's names when exporting to CSV." dir(env.WORKSPACE) { writeFile(file: "./out.txt", text: "First line") writeFile(file: "./out.txt", text: s) def f = readFile(file:"./out.txt") println f } } } The way I have it, I only get the last string I wrote. I don’t want to use the echo shell command to do this. Answer: def content = readFile(file:"out.txt") content+="new line\n" writeFile(file:"out.txt", content) or try java/groovy file class if allowed for you new File("${env.WORKSPACE}/out.txt").append("new line") If you have better answer, please add a comment about this, thank you! groovy jenkins-pipeline
Resolved: How to make statement case insensitive when uploading a dta file with specified columns?27/03/2023