diff --git a/src/main/resources/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep/help.html b/src/main/resources/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep/help.html index e60d16906..48522a71e 100644 --- a/src/main/resources/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep/help.html +++ b/src/main/resources/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep/help.html @@ -1,14 +1,69 @@
- Takes a map from branch names to closures and an optional argument failFast
- which will terminate all branches upon a failure in any other branch:
-
- parallel firstBranch: {
- // do something
- }, secondBranch: {
- // do something else
- },
- failFast: true|false
-
+ Takes a map from branch names to closures and runs the closures in
+ parallel. The failFast option terminates
+ all branches as soon as any branch fails.
+
+ + Synopsis: +
+ parallel firstBranch: {
+ // do something
+ }, secondBranch: {
+ // do something else
+ },
+ failFast: true
+
+
+ + A branch succeeds if it returns normally. The actual value + returned does not matter. A branch is considered to have failed if its + closure exits by throwing an exception. +
+
+ If any branch fails, the parallel step will throw that
+ exception once all branches have finished executing or been terminated,
+ depending on failFast mode. Any non-identical exceptions
+ thrown by other branches are added to the first exception as having been
+ “suppressed by” the first exception; see
+ Throwable.addSuppressed(...).
+
+ Note that a hudson.AbortException, as thrown by failing
+ steps (for example sh with a nonzero exit status),
+ will stop and fail the branch but not produce a stack trace.
+ This produces a:
+
+ [branchname] Failed in branch branchname ++ message without any details. + +
+ To report results from branches to the outer script, use the closure’s + access to the outer scope’s variables. For example, to run a shell script + in parallel on each of a list of arguments and produce a map of argument + to script stdout: +
+ def args = ['foo', 'bar', 'baz']
+ def results = [:]
+ // Produce a map of args to closures that use each arg
+ branches = args.collectEntries { arg -> [arg: {
+ def out = sh script: "./my-script.sh '${arg}'", returnStdout: true
+ results[arg] = out
+ } ] }
+ branches.failFast = true
+ parallel branches
+
+ If all of the branches succeeded, the 'results' array contains a map of arg
+ to shell stdout string. Otherwise parallel terminates the
+ other branches and re-throws the Exception from
+ the first failed script.
+
+
+ Note: Branch closures may return null or just nothing specific. The return
+ value of the parallel step should be ignored.
+ parallel does capture the return values of closures and
+ return a map of branch name to return value. But relying on this is not
+ recommended and the behaviour is subject to change (JENKINS-26033).
+