April 2, 2013

Jenkins - Multijob Plugin - Null Pointer Exception

Jenkins Multijob plugins comes handy when you wanted to run some set of jobs in parallel or a combination of sequential or parallel.
Here is a small discussion around the Null Pointer Exception with Multijob Plugin and the fix for the same.

Environment Details:
Jenkins 1.499
Multijob Plugin version 1.7 (parameterized-trigger.jpi is mandatory for Multijob plugin)

Problem Statement:
We have 3 defined using Multijob plugin as follows
 Multijob_Parent
         Multijob_1A
         Multijob_1B

When you run the top level job (sayMultijob_Parent), sometimes the following issue occurs

C:\Program Files (x86)\Jenkins\jobs\MultiJob_Parent\workspace>exit 0
Starting build job MultiJob_1A.
Starting build job  MultiJob_1B.
Finished Build :  #34 of Job :  MultiJob_1A with status :SUCCESS
Finished Build : #23 of Job :  MultiJob_1B with status :SUCCESS
FATAL: null
java.lang.NullPointerException
        at com.tikal.jenkins.plugins.multijob.MultiJobBuild$MultiJobRunnerImpl.evaluateResult(MultiJobBuild.java:69)
        at com.tikal.jenkins.plugins.multijob.MultiJobBuild$MultiJobRunnerImpl.isFailure(MultiJobBuild.java:59)
        at com.tikal.jenkins.plugins.multijob.MultiJobBuild$MultiJobRunnerImpl.run(MultiJobBuild.java:51)
        at hudson.model.Run.execute(Run.java:1543)
        at hudson.model.Run.run(Run.java:1489)
        at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:43)
        at hudson.model.ResourceController.execute(ResourceController.java:88)
        at hudson.model.Executor.run(Executor.java:236)

In this example, both Multijob_1A & Multijob_1B have succeeded but Multijob_Parent have failed with null pointer exception.
Assume a senario where you have 3 levels of jobs, sometimes failure in 3rd level, might have prevented some jobs to start, which is even more dangerous.                        

Solution:

Here is the fix - https://issues.jenkins-ci.org/browse/JENKINS-16042, provided by authors and follow the below steps to upgrade the Multijob Plugin.

Steps to upgrade the Multijob Plugin:
  1. Upload hpi suggested in the above link.
  2. Click "Install without restart" button
  3. Go to Manage jenkins -> Manage Plugin -> Installed -> uninstall the multijob plugin.
  4. Go to Manage jenkins - Click "Prepare for shutdown"
  5. Stop Jenkins Service
  6. Start Jenkins Service
  7. View the plugin version under installed plugin - should be updated to snapshot version by now
  8. Verify that the multijobs are in place.

No comments:

Post a Comment