1

我在 jenkins 中运行 groovy,我想从功能中拆分数据。我试图用变量名和值创建一个映射,但它看起来像函数内部的函数搞砸了。我想在不复制代码的情况下提取 CurrentBuildNo、ProjectName、Results_Folder(它们对于每个并行运行都不同)。

autotests = parallel (
  { ignore(ABORTED) { 
     retry ( 2 ) {
       build("AutoTest", CurrentBuildNo: CurrentBuildNo, ProjectName: params["ProjectName"], Results_Folder: Results_Folder) 
   } } },
  { ignore(ABORTED) { 
     retry ( 2 ) {
       build("AutoTest", CurrentBuildNo: CurrentBuildNo, ProjectName: params["ProjectName"], Results_Folder: Results_Folder) 
   } } }
)

我想要的逻辑是这样的:

tests = {{CurrentBuildNo: CurrentBuildNo, ...},{CurrentBuildNo: CurrentBuildNo, ...}}
autotests = parallel (
  for (i in tests){
     ignore(ABORTED) { 
        retry ( 2 ) {
           build("AutoTest", test[i]['CurrentBuildNo'], test[i]['ProjectName']...) 
      } } }
  }
)
4

1 回答 1

0

啊,我你会想要这样的东西:

def tests = [ [ CurrentBuildNo: CurrentBuildNo, ... ],
              [ CurrentBuildNo: CurrentBuildNo, ... ] ]

parallel tests.collect { t ->
    {
        ignore( ABORTED ) {
            retry( 2 ) {
                build( 'AutoTest', t.CurrentBuildNo, ... )
            }
        }
    }
}
于 2013-10-22T15:14:37.213 回答