[转] 在Jenkins Pipeline DSL中 遍历 groovy list
Posted pekkle
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[转] 在Jenkins Pipeline DSL中 遍历 groovy list相关的知识,希望对你有一定的参考价值。
[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}
以上是关于[转] 在Jenkins Pipeline DSL中 遍历 groovy list的主要内容,如果未能解决你的问题,请参考以下文章
Jenkins:使用 job-dsl/pipeline 语法的多个 cron 表达式
jenkins DSL pipeline timeout设置
jenkins DSL pipeline timeout设置