Groovy could be used as the configuration file for Jenkins workflow. Although I totally don’t make head or tail of Groovy, its syntax is not hard to learn.

How to iterate a list

To export a bunch of tables to CSV format, we could use

[
  "table1",
  "table2",
  "table3",
].each {
  table_name ->
  sh "export ${table_name} to ${table_name}.csv"
}

Get the output of the shell

We could run shell commands in the Groovy file and then get its output.

all_files = sh (
    script: 'ls -lh',
    returnStdout: true
).trim()
echo "All files: ${all_files}"