jenkinsci/jenkins — pull request #1092 by jbrejner (2014-01-16 11:57:01+00:00)
Title: [FIXED JENKINS-21394] Avoid irrelevant job queing while node is offline

This Fixes issue 21394.

For a job that:
polls SCM and
the SCM requires a workspace for polling

When a workspace is not available, Jenkins will submit a build to create a workspace so the polling can run, and when the submitted build runs, it will return "Nothing To Do" - a grey build, because most of the times there actually was no change in SCM, which means that the build essentially was unnessecary.

The obvious reason for non available workspace is that the workspace does not exist at all, job never ran or workspaces was deleted. The other reason would be that the slave, which has an existing, valid workspace, is offline when polling time occurs.

My change evaluates if all the slaves or nodes that is allowed to run this job are offline.
If any acceptable node is online but does not have a workspace, the job is submitted, but if no acceptable nodes are online, I will not submit the build, but wait for a suitable node to come online.