Groovy闭包(一个闭包函数groovy中有多个Shell命令)

时间:2018-08-05 18:08:43

标签: shell jenkins groovy jenkins-pipeline

我在groovy中有以下命令,我想在一个闭包函数中定义它们,并相应地传递参数。

示例:

sitebyspec <- structure(list(ID = structure(c(1L, 2L, 3L, 4L, 1L, 1L, 2L, 4L, 
 2L, 1L), .Label = c("SB1", "SB2", "SB3", "SB4"), class = "factor"), 
x = c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), y = 1:10, 
z = structure(c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 4L), .Label = c("A", 
"B", "C", "D", "E"), class = "factor"), year = c(1999, 1999, 
1999, 2000, 2001, 2000, 2001, 2001, 2002, 2002)), .Names = c("ID", 
 "x", "y", "z", "year"), row.names = c(NA, -10L), class = "data.frame")

任何建议都值得赞赏。在构建闭包时,我正在遵循教程要点中的教程,但是从该教程中我对我并不清楚。

1 个答案:

答案 0 :(得分:0)

尝试

 def mp = ["somefile.1" : "path1", "somefile.2" : "path2","somefile.3" : "path3"]             

     mp.each {sh """curl -0 https://url.com/${it.value}/${it.key}
      aws s3 copy ./${it.key} s3:bucket"""}