-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
Jenkins 2.32.1
InfluxDB Plugin 1.10.1
When invoking InfluxDB Plugin in a Pipeline script, it will throw java.lang.NullPointerException since the build has not finished and hudson.model.Run.getResult() will return null. This exception (unless caught) makes the build fail.
Step:
step([$class: 'InfluxDbPublisher', customData: null, customDataMap: null, customPrefix: null customPrefix: "<REDACTED>", target: "<REDACTED>"])
Build output:
[InfluxDB Plugin] Publishing data to: [url=<REDACTED>, description=<REDACTED> username=<REDACTED>, password=*****, database=<REDACTED>] ... java.lang.NullPointerException at jenkinsci.plugins.influxdb.generators.JenkinsBasePointGenerator.generate(JenkinsBasePointGenerator.java:54) at jenkinsci.plugins.influxdb.InfluxDbPublisher.perform(InfluxDbPublisher.java:203) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) at hudson.security.ACL.impersonate(ACL.java:221) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Finished: FAILURE
Related line in InfluxDB Code: https://github.com/jenkinsci/influxdb-plugin/blob/1.10.1/src/main/java/jenkinsci/plugins/influxdb/generators/JenkinsBasePointGenerator.java#L54
Related documentation for Jenkins API:
http://javadoc.jenkins.io/hudson/model/Run.html#getResult()
Workaround:
try { // Build things here if(currentBuild.result == null) { currentBuild.result = "SUCCESS" } } catch (err) { if(currentBuild.result == null) { currentBuild.result = "FAILURE" } throw err } finally { step([$class: 'InfluxDbPublisher', ... }