I have a jenkins multibranch pipeline where I run terragrunt code, in order to clean up the output logs I would like to redirect the terragrunt destroy output to a txt file and archive it.
Locally everything works as expected, but on jenkins the txt file is empty
i have attempted:
destroy > file.txt
destroy >> file.text
destroy 2>&1 >> file.txt
destroy >> file.txt 2>&1
destroy |& sed 's/\x1b\[[0-9;]*m//g' &>> file.txt
The last one was on the recommendation from a co-worker that it might have to do with the color output.
Scope of work:
sh "touch file.txt"
locations.each {
dir(it){
sh 'terragrunt destroy 2>&1 >> file.txt'
}
}
Not sure what else to try, all the other methods ive looked at seem to also still output to the console which defeats the goal of cleaning up the console output for readability.