Folded CpsStepContext specific safepoint handling to ThreadTask
Eliminated the running flag from AtomNode.

Instead, we are now treating all the live heads as running.
Adding block start/end node for a step that has the body.

I still need to create nodes from the body invocation and put them somewhere
Adding a proper parent node
We think this is fine because the parallel step is CPS-specific and won't get implemented as a step.
Jesse points out that this should probably move to the core at some point.
For Steps that have body, grow the flow node graph as the body is evaluated.

This change also introduced a hook for the parallel step to grow multiple branches concurrently.
If Step invokes the body multiple times, that seems fine to me.

In the async mode this is allowed anyway.
If the body is invoked concurrently, give each a unique head.
Updated the fix to keep up with the code change.

Now we have BlocKEndNode inserted, so how we get to AtomNode for the shell step needs to be tweaked.

Also, I believe the test code has a race condition; after shell script checker has run, we need to let the workflow
to "return" from the shell method and run to the completion.
getNode() looks at the cache (aka PersistenceContext.references),

... so the save operation should update that, too
Catch this common error that Step implementation makes.

Previously this was reported as NPE inside the replay() method
Newly created FlowNode need not try to load actions from storage

... as it's guaranteed to be empty.

Reference: https://trello.com/c/lqyQtW9e/19-flownode-actions-storage-weirdness
Now that retry step creates additional flow nodes for its body,
the error message printed from it in case of a failure is not reported in order --- it
gets attributed to BlockStartNode of the retry node.

This breaks the ordering of the output message (see the following dump).

This change just fixes the test assertion to accept this.

In a long run, RetryStep needs to be able to create additional start/end block node
and attribute the error there. This involves being able to track CpsThreads used to
run each body.

=== Starting testRetry(org.jenkinsci.plugins.workflow.job.WorkflowJobNonRestartingTest)
Started
Running: retry : Start
Trying!
Trying!
Trying!
Done!
ERROR: Execution failed
java.util.NoSuchElementException
    at Script1.run(Script1.groovy:6)
    at Unknown.Unknown(Unknown)
    at ___cps.transform___(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:90)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
    at com.cloudbees.groovy.cps.Next.step(Next.java:53)
    at com.cloudbees.groovy.cps.Next.run(Next.java:44)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:109)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:137)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:149)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:55)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$1.call(CpsThreadGroup.java:105)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$1.call(CpsThreadGroup.java:102)
    at org.jenkinsci.plugins.workflow.cps.AtmostOneTaskExecutor$1.call(AtmostOneTaskExecutor.java:90)
    at org.jenkinsci.plugins.workflow.cps.AtmostOneTaskExecutor$1.call(AtmostOneTaskExecutor.java:80)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Retrying
ERROR: Execution failed
java.util.NoSuchElementException
    at Script1.run(Script1.groovy:6)
    at Unknown.Unknown(Unknown)
    at ___cps.transform___(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:90)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
    at com.cloudbees.groovy.cps.Next.step(Next.java:53)
    at com.cloudbees.groovy.cps.Next.run(Next.java:44)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:109)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:137)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:149)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:55)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$1.call(CpsThreadGroup.java:105)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$1.call(CpsThreadGroup.java:102)
    at org.jenkinsci.plugins.workflow.cps.AtmostOneTaskExecutor$1.call(AtmostOneTaskExecutor.java:90)
    at org.jenkinsci.plugins.workflow.cps.AtmostOneTaskExecutor$1.call(AtmostOneTaskExecutor.java:80)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Retrying
Running: retry : End
Over!
Running: End of Workflow
Finished: SUCCESS
Merge commit '02c5078792dba9f166eea2d18e89b7eb3a6b5122'