[From] https://stackoverflow.com/questions/36360097/iterating-a-groovy-list-in-jenkins-pipeline-dsl

 

// 定义一个List,并向里面加入一些元素
def componentList = [] def componentMapEntry1 = [:] componentMapEntry1['componentName']="Dashboard_Core" componentList << componentMapEntry1 def componentMapEntry2 = [:] componentMapEntry2['componentName']="Dashboard_Equities" componentList << componentMapEntry2 def cme3 = [:] cme3["componentName"] = "home" componentList << cme3

 

echo "size of list "+componentList.size()

// pipeline里打印size() [Pipeline]
echo size of list 3

 

println componentList

// pipeline里直接打印list [Pipeline]
echo [{componentName=Dashboard_Core}, {componentName=Dashboard_Equities}, {componentName=home}]

 

for (i = 0; i <componentList.size(); i++) {
    println componentList[i]
}

// pipeline里遍历list
[Pipeline] echo
{componentName=Dashboard_Core}
[Pipeline] echo
{componentName=Dashboard_Equities}
[Pipeline] echo
{componentName=home}

 

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2021-08-19
  • 2022-01-14
  • 2021-12-06
  • 2021-11-03
  • 2022-02-13
  • 2022-01-10
猜你喜欢
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
相关资源
相似解决方案