我正在通过jenkins调用Powershell脚本,并且从powershell脚本获取输出值,似乎发生的是,如果由于某种原因输出值为null,则jenkins管道将失败,并出现以下错误。
代码可以在下面找到
stage('Get Ticket Number') {
steps {
script {
env.New_Ticket = powershell(returnStdout: true,script: '.\\New_Ticket.ps1')
}
}
}
def ticket_json = readJSON文本:“ $ {env.New_Ticket}” 回声“ Ticket:” + ticket_json.ticketno
错误详细信息可以在下面找到。
hudson.remoting.ProxyException: net.sf.json.JSONException: Invalid JSON String
at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:143)
at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:103)
at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:84)
at org.jenkinsci.plugins.pipeline.utility.steps.json.ReadJSONStepExecution.doRun(ReadJSONStepExecution.java:79)
at org.jenkinsci.plugins.pipeline.utility.steps.json.ReadJSONStepExecution.doRun(ReadJSONStepExecution.java:48)
at org.jenkinsci.plugins.pipeline.utility.steps.AbstractFileOrTextStepExecution.run(AbstractFileOrTextStepExecution.java:32)
at org.jenkinsci.plugins.workflow.steps.SynchronousnonBlockingStepExecution.lambda$start$0(SynchronousnonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.Futuretask.run(Futuretask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE