I need to output the result of this shell script "git diff --name-only commit2 commit1" to an array in groovy. How can I do it?
Already tried to create a variable
def diff = sh(script: "git diff --name-only commit2 commit1", returnStdout: true)
and then work it with Pattern and Matcher, but probably due to its formatting it is always returning an empty array.
The output of the shell script is something like:
directory/file1.java
directory/file2.java
Found a way to do it with bash but can't figure out how to adapt it to groovy (mapfile -t my_array < <( my_command ))