OK9*_*999 2 groovy jenkins-pipeline
任何想法为什么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;
}
}
Run Code Online (Sandbox Code Playgroud)
而下面的那个没有
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;
}
}
Run Code Online (Sandbox Code Playgroud)
为什么我需要专门将a转换string为Integer,而无法将其作为string数据类型进行比较?
| 归档时间: |
|
| 查看次数: |
1070 次 |
| 最近记录: |