Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在Jenkins groovy中执行减法_Jenkins_Groovy_Jenkins Pipeline - Fatal编程技术网

无法在Jenkins groovy中执行减法

无法在Jenkins groovy中执行减法,jenkins,groovy,jenkins-pipeline,Jenkins,Groovy,Jenkins Pipeline,我有一个建造管道。我还在学groovy。我在做这样简单的事情 stage('test'){ def temp = 3 \\ reading this value from other env variable while(temp != 1) { temp=temp-1 echo temp } } 它总是呼应着3,而这是永无止境的 当您从环境变量中读取值时,将其作为字符串获取 您需要将其转换为整数 def temp = env.SOMETHING.toInteger() 或者,将其定义为

我有一个建造管道。我还在学groovy。我在做这样简单的事情

stage('test'){
def temp = 3 \\ reading this value from other env variable 
while(temp != 1) {
temp=temp-1
echo temp
}

}

它总是呼应着3,而这是永无止境的

当您从环境变量中读取值时,将其作为字符串获取

您需要将其转换为整数

def temp = env.SOMETHING.toInteger()
或者,将其定义为整数,而不是使用
def

int temp = env.SOMETHING

当您从环境变量中读取值时,它是作为字符串获取的

您需要将其转换为整数

def temp = env.SOMETHING.toInteger()
或者,将其定义为整数,而不是使用
def

int temp = env.SOMETHING

非常感谢。完美无瑕,谢谢。工作完美无瑕。