聚合国内IT技术精华文章,分享IT技术精华,帮助IT从业人士成长

Some tips in groovy of Jenkins

2021-07-23 09:40 浏览: 2807306 次 我要评论(0 条) 字号:

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}"


网友评论已有0条评论, 我也要评论

发表评论

*

* (保密)

Ctrl+Enter 快捷回复