Aman .sinha
Aman .sinha

Reputation: 53

Convert a string with /n into comma separated string in Groovy

I have a string in groovy where every item is a new line

change_list = sh returnStdout: true, script: 'cd $WORKSPACE/p4c && git diff ${cid} origin/${CHANGE_TARGET} --name-only'

print change_list

print change_list.getClass()

Below is the output

Jenkinsfile

extensions/idpf/BaseCtrlTables.cpp

extensions/idpf/CollectProgramData.cpp

extensions/idpf/CollectProgramData.h

extensions/idpf/FormApplyTree.cpp

I want to convert it into a string with the newline changed as comma separated, or a new list with each element as 1 item

Upvotes: 1

Views: 438

Answers (1)

Related Questions