[FIXED JENKINS-18931] Build is triggered incorrectly when a triggered build starts running.

Context should be calculated against a completed build not an in progress one.
use the buildId in the context to check against - to avoid a race condition.
Merge pull request #6 from jtnord/JENKINS-18931

Fixes Jenkins-18931