Loading
close

当执行流水线时提示java.lang.NullPointerException,如何排查解决?

time 更新时间:2022-02-18 23:13:27

问题描述

当执行流水线时,执行状态显示失败。之后,在查看此次运行记录的详情时,发现提示 java.lang.NullPointerException 报错。

[2021-05-08T07:00:40.996Z] java.lang.NullPointerException
[2021-05-08T07:00:40.996Z]  at org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave.getKubernetesCloud(KubernetesSlave.java:233)
[2021-05-08T07:00:40.996Z]  at org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave.getKubernetesCloud(KubernetesSlave.java:225)
[2021-05-08T07:00:40.996Z]  at org.csanchez.jenkins.plugins.kubernetes.pipeline.KubernetesNodeContext.connectToCloud(KubernetesNodeContext.java:59)
[2021-05-08T07:00:40.996Z]  at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator.getClient(ContainerExecDecorator.java:150)
[2021-05-08T07:00:40.996Z]  at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.doLaunch(ContainerExecDecorator.java:371)
[2021-05-08T07:00:40.996Z]  at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.launch(ContainerExecDecorator.java:336)
[2021-05-08T07:00:40.996Z]  at hudson.Launcher$ProcStarter.start(Launcher.java:454)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:234)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:103)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:317)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:286)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1138)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
[2021-05-08T07:00:40.996Z]  at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
[2021-05-08T07:00:40.996Z]  at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
[2021-05-08T07:00:40.996Z]  at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
[2021-05-08T07:00:40.996Z]  at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
[2021-05-08T07:00:40.996Z]  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
[2021-05-08T07:00:40.996Z]  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
[2021-05-08T07:00:40.996Z] Caused: java.lang.RuntimeException
[2021-05-08T07:00:40.996Z]  at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator.getClient(ContainerExecDecorator.java:152)
[2021-05-08T07:00:40.996Z]  at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.doLaunch(ContainerExecDecorator.java:371)
[2021-05-08T07:00:40.996Z]  at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.launch(ContainerExecDecorator.java:336)
[2021-05-08T07:00:40.996Z]  at hudson.Launcher$ProcStarter.start(Launcher.java:454)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:234)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:103)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:317)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:286)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1138)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
[2021-05-08T07:00:40.996Z]  at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
[2021-05-08T07:00:40.996Z]  at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
[2021-05-08T07:00:40.996Z]  at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
[2021-05-08T07:00:40.996Z]  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
[2021-05-08T07:00:40.996Z]  at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
[2021-05-08T07:00:40.996Z]  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
[2021-05-08T07:00:40.996Z]  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
[2021-05-08T07:00:40.996Z]  at WorkflowScript.run(WorkflowScript:63)
[2021-05-08T07:00:40.996Z]  at ___cps.transform___(Native Method)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
[2021-05-08T07:00:40.996Z]  at sun.reflect.GeneratedMethodAccessor240.invoke(Unknown Source)
[2021-05-08T07:00:40.996Z]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2021-05-08T07:00:40.996Z]  at java.lang.reflect.Method.invoke(Method.java:498)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
[2021-05-08T07:00:40.996Z]  at sun.reflect.GeneratedMethodAccessor298.invoke(Unknown Source)
[2021-05-08T07:00:40.996Z]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2021-05-08T07:00:40.996Z]  at java.lang.reflect.Method.invoke(Method.java:498)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.Next.step(Next.java:83)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
[2021-05-08T07:00:40.996Z]  at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
[2021-05-08T07:00:40.996Z]  at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
[2021-05-08T07:00:40.996Z]  at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
[2021-05-08T07:00:40.996Z]  at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
[2021-05-08T07:00:40.996Z]  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2021-05-08T07:00:40.996Z]  at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
[2021-05-08T07:00:40.996Z]  at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
[2021-05-08T07:00:40.996Z]  at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
[2021-05-08T07:00:40.996Z]  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[2021-05-08T07:00:40.996Z]  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2021-05-08T07:00:40.996Z]  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[2021-05-08T07:00:40.996Z]  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[2021-05-08T07:00:40.996Z]  at java.lang.Thread.run(Thread.java:748)
[2021-05-08T07:00:40.996Z] Finished: FAILURE

此时,在集群配置页面中,可能会同时看到集群名称后有异常提示,提示信息为“业务集群已经被删除,请配置新的业务集群”,或者也可能会看到集群配置页面中未配置集群,集群已被自动移除。

问题原因

当前承载流水线运行的Kubernetes集群已被删除,无法正常连接。

解决方案

方案一:直接更改Kubernetes集群

  1. (可选)移除旧集群。

    当已删除集群未在集群配置页面被自动移除时,请执行以下操作移除该旧集群。反之,可跳过本步骤。

    在云平台的顶部导航栏中,依次选择[产品与服务]-[DevOps]-[集群配置],进入“集群配置”页面。在该页面中,单击列表上方的 移除 ,弹出“移除集群”提示框。在该提示框中,单击 移除 ,移除该旧集群,并关闭提示框。

  2. 添加新集群。

    在云平台的顶部导航栏中,依次选择[产品与服务]-[DevOps]-[集群配置],进入“集群配置”页面。在该页面中,单击页面上方的 添加集群 ,弹出“添加集群”对话框。在该对话框中,选择用于承载流水线运行的新集群后,单击 添加 ,开始添加Kubernetes集群,并关闭对话框。

方案二:重新配置该Kubernetes集群

配置Kubernetes集群的具体操作步骤,请参考 配置集群

当上述Kubernetes集群配置成功且状态为“健康”状态时,DevOps功能会自动恢复正常,可以直接按需重新执行上述流水线。

此篇文章对你是否有帮助?
没帮助
locked-file

您暂无权限访问该产品