[FIXED JENKINS-20662] Establish relation to new build immediately.
[JENKINS-20662] Add test.
[JENKINS-20662] Simplify test after feedback
Merge branch 'JENKINS-20662' of github.com:daniel-beck/jenkins
[JENKINS-20662] Noting merge of #1191.