[英]How To Pass a Groovy Array to Shell Script in Jenkins
I need to get the array that I have in my groovy Script and pass it shell Script for further Calculation in the Shell Script我需要获取我在 groovy 脚本中的数组并将其传递给 shell 脚本,以便在 Shell 脚本中进行进一步计算
I have tried multiple was but I am not getting the array passed to Shell Script.我尝试了多个,但我没有将数组传递给 Shell 脚本。
templates = ["Temp1","Temp2","Temp3"]
templateCount = templates.size()
sh """
count = ${templateCount}
temp = ${templates}
for (( i=0; i < count; i++ ))
do
echo "Template Name = " ${temp[i]}
done
"""
Try one of the following options.尝试以下选项之一。
script {
def templates = ["Temp1","Temp2","Temp3"]
sh """
for v in ${templates.join(' ')}
do
echo \$v
done
"""
// Option 2
for(tmp in templates) {
sh "echo ${tmp}"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.