从jenkinsfile运行shell命令

时间:2017-11-20 09:13:48

标签: jenkins groovy jenkins-pipeline

我为一个回购配置了jenkins管道作业。从jenkinsfile我正在运行像

这样的命令
statusCode = sh (script: "java -jar assembly.jar --file 
${workingDir}/excel/Case-Metadata.xlsx --name ${workingDir}/opCo.json --json 
${workingDir}/opCo.json --pot opCo.pot", returnStatus: true )
//printing value of statusCode as
sh "echo 'command status is ${statusCode}'"
if (statusCode != 0)
{
   currentBuild.result = 'FAILURE'
   error "Shell command failed"
}

当我运行该作业时,它会抛出错误,如

java.lang.NullPointerException at FXSheet$$anonfun$getcaseCategories$1$$anonfun$apply$mcVI$sp$26$$anonfun$apply$mcVI$sp$27.apply$mcVI$sp(FXSheet.scala:969)

,即使命令失败,statusCode的值也会变为'0'。

0 个答案:

没有答案
相关问题