知道下面IF-ELSE
的工作原理
def checkPrValidity() {
wordCountStr = sh returnStdout: true, script: 'git diff --ignore-space-at-eol $target_branch..PRbranch src | wc -l'
wordCount = wordCountStr.toInteger() //force conversion to int data type
if (wordCount == 0) {
return false;
} else {
println("This is a valid PR, continue the job execution")
return true;
}
}
而下面的那个没有
def checkPrValidity() {
wordCountStr = sh returnStdout: true, script: 'git diff --ignore-space-at-eol $target_branch..PRbranch src | wc -l'
if (wordCountStr == '0') {
return false;
} else {
println("This is a valid PR, continue the job execution")
return true;
}
}
为什么我需要专门将string
转换为Integer
,而无法将其作为string
数据类型进行比较?