Any idea why the IF-ELSE
below works
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;
}
}
while the one below doesn't
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;
}
}
Why do i need to specifically convert a string
to Integer
, while it fails to compare it as a string
data type?