[英]Unable to do subtraction in Jenkins groovy
我有一個構建管道。 我還在學習 groovy。 我正在做這樣簡單的事情
stage('test'){
def temp = 3 \\ reading this value from other env variable
while(temp != 1) {
temp=temp-1
echo temp
}
}
它總是與 3 相呼應,而 while 是永無止境的。
當您從環境變量中讀取值時,您將其作為字符串獲取
您需要將其轉換為 Integer
def temp = env.SOMETHING.toInteger()
或者,將其定義為 integer 而不是使用def
:
int temp = env.SOMETHING
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.