Adding a test case that forks off a lot of parallel branches.

... in an attempt to exaggerate the problem.

https://gist.githubusercontent.com/kohsuke/1853b6c2052d01dcaf92/raw/e87e2dad2b2a3f07f3f67bd42f4f6c5fdecbd6e7/gistfile1.txt
Revisting the threading model.

Designate a thread as a CPS VM execution thread, and ensure that various critical methods can be only invoked from that thread.

With that assertion in place, remove locks that results in a deadlock such as https://trello.com/c/7aTFYWM5/26-intermittent-deadlock
and https://gist.githubusercontent.com/kohsuke/1853b6c2052d01dcaf92/raw/e87e2dad2b2a3f07f3f67bd42f4f6c5fdecbd6e7/gistfile1.txt
Lock reduction

GraphListener might do anything, so don't call it while holding a lock
Acting on CpsThreadGroup from CpsFlowExecution is a common pattern, so create an idiom

... to schedule a task in CpsVmThread
Fixed a race condition.

There's a time lag between

(A) FlowExecution.isComplete() starts returning true,
(B) Future from scheduleRun() signals completion, and
(C) WorkflowRun.finish() call happens to set the final result.

It used to be that the order in which this happens was (A) > (C) > (B)
because head updates and listener notifications happen before Future
signals.

With the change in the previous commit, now the order of the event is
(A) > (B) > (C), which breaks various tests that expect WorkflowRun
to have the final result when CpsFlowExecution completes.

This change fixes back the order.
Cleaning up remaining test failures.

They are all test problems.
shutdown the executor pool when CpsThreadGroup is done
if a file doesn't exist, serve something empty
Fixed a race condition.

execution.isComplete() becomes true before all the listeners are invoked (which is necessary
because the nodes have to appear as heads before the listener can be called.)

When it happens, waitForCompletion() would return, causing the flyweight executor to quit,
making QueueTaskFuture to be marked as done. All this happen before finish() method gets
called and set the result.

In this change, I'm making waitForCompletion() actually wait until the finish() method runs.
Reducing the # of branches.

Otherwise Jenkins seems to have trouble building this in a timely
fashion
Record a step failure in FlowNode.
Merge commit '51d96b2ea4aa823bcd5cc42d0006477b086bd437'
If the program has completed, don't try to load the state again
let the reference go when the workspace is released.

Otherwise this callback can still end up getting captured in the object graph (for example if a closure escapes the with.node { ... } scope, which then implicitly captures all the current environment including this one.)

This fixes
https://trello.com/c/XNgDogCv/65-bug-checkpoint-cannot-be-restarted-twice
Merge commit '106de615f23be236bbc5fc2bdbe340ee979cb59f'
Merge branch 'master' into single-thread

Conflicts:
	job/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java
stage is not a built-in.
Merge REMERGE_HEAD
Renaming groupId and artifactId for plugins.
Merge branch 'master' of github.com:jenkinsci/workflow-plugin