You cannot redirect a string:
execute("echo hello > file")
Therefore, nothing is written to the file. The easiest way to handle this is probably to wrap all your commands in one shell script, and then execute that script.
echo ( > file), file Groovy.
:
execute( [ 'bash', '-c', 'echo hello > file' ] )
execute, List.execute()