[FIXED JENKINS-22974] - NPE in makeUserVars if an upstream build is missing

The PR contains the bugfix and the direct test case.
AFAIK, the newest Jenkins core versions contain annotations for <code>Job::getBuildByNumber()</code>, hence developers will be notified about such issues.