標籤:++ bsp entry color print span jenkin dashboard iter
[From] https://stackoverflow.com/questions/36360097/iterating-a-groovy-list-in-jenkins-pipeline-dsl
// 定義一個List,並向裡面加入一些元素
def componentList = []def componentMapEntry1 = [:]componentMapEntry1[‘componentName‘]="Dashboard_Core"componentList << componentMapEntry1def componentMapEntry2 = [:]componentMapEntry2[‘componentName‘]="Dashboard_Equities"componentList << componentMapEntry2def cme3 = [:]cme3["componentName"] = "home"componentList << cme3
echo "size of list "+componentList.size()
// pipeline裡列印size()[Pipeline] echosize 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}
[轉] 在Jenkins Pipeline DSL中 遍曆 groovy list