我有一個名為卷的檔案,其中包含卷串列,以空格分隔。這是檔案內容的示例
vol-0e9cd38819c7a6cb8 vol-0baba5cee0c7fc89a vol-0e7fae905aaffe3a1
我可以通過在sh中使用這個回圈來洗掉所有這些:
for volume in $(cat volumes); do; aws ec2 delete-volume --volume-id $volume; done
但是當我嘗試在 Jenkinsfile 中這樣做時:
sh "for volume in \$(cat volumes); do; aws ec2 delete-volume --volume-id \$volume; done"
我收到以下錯誤:
syntax error near unexpected token `;'
我試圖以不同的方式和不同型別的sh塊來轉義字符,但這沒有幫助,我仍然得到同樣的錯誤。
請幫我解決這個問題。
uj5u.com熱心網友回復:
沒有;后do。它的:
for volume in $(cat volumes); do aws ec2 delete-volume --volume-id $volume; done
for i in $(cat是一種反模式。https://mywiki.wooledge.org/BashFAQ/001。在這種情況下,我會使用 xargs。
xargs -n1 aws ec2 delete-volume --volume-id < volumes
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/508709.html
標籤:詹金斯嘘
下一篇:獲取java.io.NotSerializableException:jenkins中的org.jenkinsci.plugins.workflow.job.WorkflowJob錯誤
