Fix exception in MatrixBuild.java:371

Happens when build has no parent:

15:06:14 FATAL: null
15:06:14 java.lang.NullPointerException
15:06:14    at hudson.matrix.MatrixBuild$MatrixBuildExecution.doRun(MatrixBuild.java:371)
15:06:14    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:580)
15:06:14    at hudson.model.Run.execute(Run.java:1575)
15:06:14    at hudson.matrix.MatrixBuild.run(MatrixBuild.java:304)
15:06:14    at hudson.model.ResourceController.execute(ResourceController.java:88)
15:06:14    at hudson.model.Executor.run(Executor.java:237)
15:06:14    at hudson.model.OneOffExecutor.run(OneOffExecutor.java:66)
Merge pull request #746 from saschpe/master-jenkins-16276

[JENKINS-16276] and various fixes for related exceptions