ctron / package-drone-jenkins

A Package Drone Plugin for Jenkins
3 stars 4 forks source link

NPE when upload from jenkins node and no artifacts #13

Closed nfalco79 closed 7 years ago

nfalco79 commented 7 years ago

I have a maven build that goes in error so there are no artifacts to deploy. The job is execute on a remote Jenkins node. PackageDrone goes in NPE; follow the stacktrace:

ERROR: Build step failed with exception
java.lang.NullPointerException
    at de.dentrassi.pm.jenkins.DroneRecorder$UploadFiles.invoke(DroneRecorder.java:324)
    at de.dentrassi.pm.jenkins.DroneRecorder$UploadFiles.invoke(DroneRecorder.java:266)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2731)
    at hudson.remoting.UserRequest.perform(UserRequest.java:153)
    at hudson.remoting.UserRequest.perform(UserRequest.java:50)
    at hudson.remoting.Request$2.run(Request.java:336)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
    at ......remote call to Node 03(Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1545)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
    at hudson.remoting.Channel.call(Channel.java:830)
    at hudson.FilePath.act(FilePath.java:985)
    at hudson.FilePath.act(FilePath.java:974)
    at de.dentrassi.pm.jenkins.DroneRecorder.perform(DroneRecorder.java:228)
    at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
    at hudson.model.Build$BuildExecution.post2(Build.java:186)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
    at hudson.model.Run.execute(Run.java:1753)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:405)

Looking the class the problem seems that these conditions (node + no artifacts to publish) cause the issue becuase in line 324 you access to private transient field run that is null in case the node is not master.

A workaround bould be add instead set the Result on the run varaible, set the already existing UploadFiles.failed field or new one (because failed depends on failsAsUpload)