-
Notifications
You must be signed in to change notification settings - Fork 198
[JENKINS-54514] Document error handling in the 'parallel' step #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ringerc
wants to merge
2
commits into
jenkinsci:master
Choose a base branch
from
ringerc:JENKINS-54514
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 66 additions & 11 deletions
77
src/main/resources/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep/help.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,69 @@ | ||
| <div> | ||
| <p> | ||
| Takes a map from branch names to closures and an optional argument <code>failFast</code> | ||
| which will terminate all branches upon a failure in any other branch: | ||
| </p> | ||
| <pre> | ||
| parallel firstBranch: { | ||
| // do something | ||
| }, secondBranch: { | ||
| // do something else | ||
| }, | ||
| failFast: true|false | ||
| </pre> | ||
| Takes a map from branch names to closures and runs the closures in | ||
| parallel. The <code>failFast</code> option terminates | ||
| all branches as soon as any branch fails. | ||
| </p> | ||
| <p> | ||
| Synopsis: | ||
| <pre> | ||
| parallel firstBranch: { | ||
| // do something | ||
| }, secondBranch: { | ||
| // do something else | ||
| }, | ||
| failFast: true | ||
| </pre> | ||
| </p> | ||
| <p> | ||
| 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. | ||
| </p> | ||
| <p> | ||
| If any branch fails, the <code>parallel</code> step will throw that | ||
| exception once all branches have finished executing or been terminated, | ||
| depending on <code>failFast</code> mode. Any non-identical exceptions | ||
| thrown by other branches are added to the first exception as having been | ||
| “suppressed by” the first exception; see | ||
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Throwable.html#addSuppressed(java.lang.Throwable)" target="_blank"><code>Throwable.addSuppressed(...)</code></a>. | ||
| </p> | ||
| <p> | ||
| Note that a <code>hudson.AbortException</code>, as thrown by failing | ||
| steps (for example <code>sh</code> with a nonzero exit status), | ||
| will stop and fail the branch but not produce a stack trace. | ||
| This produces a: | ||
| <pre> | ||
| [branchname] Failed in branch branchname | ||
| </pre> | ||
| message without any details. | ||
| </p> | ||
| <p> | ||
| 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: | ||
| <pre> | ||
| 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 | ||
| </pre> | ||
| If all of the branches succeeded, the 'results' array contains a map of arg | ||
| to shell stdout string. Otherwise <code>parallel</code> terminates the | ||
| other branches and re-throws the <code>Exception</code> from | ||
| the first failed script. | ||
| </p> | ||
| <p> | ||
| Note: Branch closures may return <code>null</code> or just nothing specific. The return | ||
| value of the <code>parallel</code> step should be ignored. | ||
| <code>parallel</code> 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). | ||
| </p> | ||
| </div> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbortExceptionis not necessarily thrown by failing steps.I think mentioning
AbortExceptionis misleading since it doesn't have any special interaction with theparallelstep.