您错过了一个
script街区。引用(来源):
脚本步骤采用一块脚本管道,并在声明性管道中执行。
stage('Check') { steps { script { Boolean bool = fileExists 'NewFile.txt' if(bool) { println "The File exists :)" } else { println "The File does not exist :(" } } } }基本上,在脚本块中,您可以使用所需的所有内容。Groovy,if,try-catch等等等。



