Skip to content
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

Workflow onComplete/onError handlers don't work when defined in the entry workflow #5261

Open
bentsherman opened this issue Aug 27, 2024 · 0 comments
Labels

Comments

@bentsherman
Copy link
Member

The following example:

workflow {
    params.outdir = 'results'

    workflow.onComplete {
        if( workflow.success )
            log.info "Success! View results: $params.outdir"
        else
            log.info "Failure!"
    }
}

Fails with an error that workflow is null in the onComplete handler, even though it should be in scope. The same error will happen for params if it is accessed first. These handlers should work regardless of whether they are defined at the script level or in the entry workflow.

There are two workarounds:

  1. Assign the onComplete handler: workflow.onComplete = { ...
  2. Declare local variables that reference workflow and params:
    def myParams = params
    def myWorkflow = workflow
    workflow.onComplete {
      // ...
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant